You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
`reactR` provides a set of convenience functions for using [`React`](https://facebook.github.io/react) in `R` with `htmlwidget` constructor templates and local JavaScript dependencies. The `React` ecosystem is rich with components that can enhance `R` web and Shiny apps. `scaffoldReactWidget()` helps build `htmlwidgets` to integrate these `React` components as `R``htmlwidgets`. The local dependency functions are modeled after the `html_dependency_*` functions from RStudio's [`rmarkdown`](https://github.com/rstudio/rmarkdown) package.
23
+
24
+
## Installation
25
+
26
+
You can install reactR from CRAN with `install.packages("reactR")`. For the development version, please use `devtools` as shown below.
27
+
28
+
```R
29
+
# install.packages("devtools")
30
+
devtools::install_github("react-R/reactR")
31
+
```
32
+
33
+
## Creating htmlwidgets with React Components
34
+
35
+
To wrap a `React` component as an `htmlwidget`, please see the tutorial [htmlwidgets with reactR](https://react-r.github.io/reactR/articles/intro_htmlwidgets.html). Also, there are a variety of examples in the [react-R Github organization](https://github.com/react-R).
36
+
37
+
## Examples
38
+
39
+
```R
40
+
library(reactR)
41
+
library(htmltools)
42
+
43
+
browsable(tagList(
44
+
tags$div(id="app"),
45
+
tags$script(
46
+
"
47
+
ReactDOM.render(
48
+
React.createElement(
49
+
'h1',
50
+
null,
51
+
'Powered by React'
52
+
),
53
+
document.getElementById('app')
54
+
)
55
+
"
56
+
),
57
+
#add core-js first to work in RStudio Viewer
58
+
html_dependency_corejs(),
59
+
html_dependency_react()
60
+
))
61
+
```
62
+
63
+
`reactR` also uses the `V8` package if available to transform `JSX` and `ES2015` code.
64
+
65
+
```R
66
+
library(reactR)
67
+
library(htmltools)
68
+
69
+
browsable(
70
+
tagList(
71
+
tags$div(id="app"),
72
+
tags$script(
73
+
babel_transform('ReactDOM.render(<h1>Powered By React/JSX</h1>,document.getElementById("app"))')
74
+
),
75
+
# add core-js shim first for React in RStudio Viewer
76
+
html_dependency_corejs(),
77
+
html_dependency_react()
78
+
)
79
+
)
80
+
```
81
+
82
+
## Contributing and Code of Conduct
83
+
84
+
We welcome contributors and would love your participation. Please note that this project is released with a [Contributor Code of Conduct](CONDUCT.md). By participating in this project you agree to abide by the terms.
<!-- README.md is generated from README.Rmd. Please edit that file -->
7
5
8
-
`reactR` provides a set of convenience functions for using [`React`](https://facebook.github.io/react) in `R` with `htmlwidget` constructor templates and local JavaScript dependencies. The `React` ecosystem is rich with components that can enhance `R` web and Shiny apps. `scaffoldReactWidget()` helps build `htmlwidgets` to integrate these `React` components as `R``htmlwidgets`. The local dependency functions are modeled after the `html_dependency_*` functions from RStudio's [`rmarkdown`](https://github.com/rstudio/rmarkdown) package.
You can install reactR from CRAN with `install.packages("reactR")`. For the development version, please use `devtools` as shown below.
21
+
You can install reactR from CRAN with `install.packages("reactR")`. For
22
+
the development version, please use `devtools` as shown below.
13
23
14
-
```R
24
+
```r
15
25
# install.packages("devtools")
16
26
devtools::install_github("react-R/reactR")
17
27
```
18
28
19
29
## Creating htmlwidgets with React Components
20
30
21
-
To wrap a `React` component as an `htmlwidget`, please see the tutorial [htmlwidgets with reactR](https://react-r.github.io/reactR/articles/intro_htmlwidgets.html). Also, there are a variety of examples in the [react-R Github organization](https://github.com/react-R).
31
+
To wrap a `React` component as an `htmlwidget`, please see the tutorial
Also, there are a variety of examples in the [react-R Github
35
+
organization](https://github.com/react-R).
22
36
23
37
## Examples
24
38
25
-
```R
39
+
```r
26
40
library(reactR)
27
41
library(htmltools)
28
42
@@ -46,9 +60,10 @@ browsable(tagList(
46
60
))
47
61
```
48
62
49
-
`reactR` also uses the `V8` package if available to transform `JSX` and `ES2015` code.
63
+
`reactR` also uses the `V8` package if available to transform `JSX` and
64
+
`ES2015` code.
50
65
51
-
```R
66
+
```r
52
67
library(reactR)
53
68
library(htmltools)
54
69
@@ -67,4 +82,7 @@ browsable(
67
82
68
83
## Contributing and Code of Conduct
69
84
70
-
We welcome contributors and would love your participation. Please note that this project is released with a [Contributor Code of Conduct](CONDUCT.md). By participating in this project you agree to abide by the terms.
85
+
We welcome contributors and would love your participation. Please note
86
+
that this project is released with a [Contributor Code of
87
+
Conduct](CONDUCT.md). By participating in this project you agree to
0 commit comments