Add JavaScript 'React' dependency. For this to work in RStudio Viewer, also include
html_dependency_corejs
.
html_dependency_react(offline = TRUE)
logical
to use local file dependencies. If FALSE
,
then the dependencies use the Facebook cdn as its src
.
To use with JSX
see babel_transform
.
library(reactR)
library(htmltools)
#> Warning: package 'htmltools' was built under R version 4.3.3
tagList(
tags$script(
"
ReactDOM.render(
React.createElement(
'h1',
null,
'Powered by React'
),
document.body
)
"
),
#add core-js first to work in RStudio Viewer
html_dependency_corejs(),
html_dependency_react() #offline=FALSE for CDN
)
#> <script>
#> ReactDOM.render(
#> React.createElement(
#> 'h1',
#> null,
#> 'Powered by React'
#> ),
#> document.body
#> )
#> </script>