setReactState {shinyChakraUI} | R Documentation |
Set a React state
Description
Set a React state from the Shiny server.
Usage
setReactState(session, componentId, stateName, value)
Arguments
session |
Shiny session object |
componentId |
the id of the |
stateName |
the name of the state to be set |
value |
the new value of the state; it can be an R object serializable
to JSON, a React component, a JSX element created with the
|
Value
No return value, called for side effect.
See Also
Examples
library(shiny)
library(shinyChakraUI)
ui <- chakraPage(
br(),
chakraComponent(
"mycomponent",
Tag$Button(
id = "button",
className = "action-button",
colorScheme = "facebook",
display = "block",
onClick = jseval("(event) => {event.target.disabled = true}"),
"Click me to change the content of the container"
),
br(),
Tag$Divider(),
br(),
withStates(
Tag$Container(
maxW = "xl",
centerContent = TRUE,
bg = "yellow.100",
getState("containerContent")
),
states = list(containerContent = "I am the container content.")
)
)
)
server <- function(input, output, session){
observeEvent(input[["button"]], {
setReactState(
session = session,
componentId = "mycomponent",
stateName = "containerContent",
value = Tag$Box(
padding = "4",
maxW = "3xl",
fontStyle = "italic",
fontWeight = "bold",
borderWidth = "2px",
"I am the new container content, included in a Box."
)
)
})
}
if(interactive()){
shinyApp(ui, server)
}
[Package shinyChakraUI version 1.1.1 Index]