html_dependency_mobx {reactR} | R Documentation |
Dependencies for 'mobx'
Description
Add JavaScript 'mobx' and 'mobx-react' dependency. When using with 'react', the order
of the dependencies is important, so please add html_dependency_react()
before
html_dependency_mobx()
.
Usage
html_dependency_mobx(react = TRUE)
Arguments
react |
|
Value
Examples
if(interactive()) {
library(htmltools)
library(reactR)
browsable(
tagList(
html_dependency_mobx(react = FALSE),
div(id="test"),
tags$script(HTML(
"
var obs = mobx.observable({val: null})
mobx.autorun(function() {
document.querySelector('#test').innerText = obs.val
})
setInterval(
function() {obs.val++},
1000
)
"
))
)
)
}
## Not run:
# use with react
library(htmltools)
library(reactR)
browsable(
tagList(
html_dependency_react(),
html_dependency_mobx(),
div(id="test"),
tags$script(HTML(babel_transform(
"
var obs = mobx.observable({val: null})
var App = mobxReact.observer((props) => <div>{props.obs.val}</div>)
ReactDOM.render(<App obs = {obs}/>, document.querySelector('#test'))
setInterval(
function() {obs.val++},
1000
)
"
)))
)
)
## End(Not run)
[Package reactR version 0.6.0 Index]