All examples By author By category About

timelyportfolio

R listviewer minimal implementation of react-json

I have been experimenting with React in R. Here is a quick illustration of making a htmlwidget out of react-json.

# requires dev version of listviewer
# devtools::install_github("timelyportfolio/listviewer@feature/react-json")
library(listviewer)

# use reactR for React dependencies
# devtools::install_github("timelyportfolio/reactR")
library(reactR)

reactjson()

reactjson(head(mtcars,4))
reactjson(I(jsonlite::toJSON(head(mtcars,5))))

library(shiny)

shinyApp(
  ui = reactjson(
    list(x=1,msg="react+r+shiny",opts=list(use_react=FALSE)),
    elementId = "json1"
  ),
  server = function(input, output, session){
    observeEvent(
      input$json1_change,
      str(input$json1_change)
    )
  }
)