Branch: master
Clone or download
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
R fix Rd bug with tagList Feb 16, 2019
assets/logos move logos to /assets and add to Rbuildignore Jan 10, 2019
build update react and react-dom to 16.0.0 and babel to 6.26.0; update pkgd… Oct 11, 2017
docs pkgdown Jan 18, 2019
inst restore instance Feb 13, 2019
js-tests Fix bug in xmlEqual Jan 10, 2019
man fix Rd bug with tagList Feb 16, 2019
pkgdown/favicon add favicon and build with newest pkgdown Jan 12, 2019
srcjs restore instance Feb 13, 2019
vignettes Slight rewording in scaffold vignette Jan 25, 2019
.Rbuildignore add srcjs and webpack.config.js to Rbuildignore Feb 16, 2019
.gitattributes Treat generated JS files like binaries in git diffs, github PRs Feb 11, 2019
.gitignore First cut, using webpack to build react-tools.js Feb 8, 2019
.travis.yml Travis: specify R version Jan 8, 2019
CONDUCT.md add a basic README.md and code of conduct Jun 24, 2016
DESCRIPTION update DESCRIPTION, NEWS, and cran-comments Jan 26, 2019
LICENSE increment version, update NEWS, and prep for CRAN Feb 21, 2018
NAMESPACE Rename reactData => reactMarkup Jan 9, 2019
NEWS.md update NEWS.md to track all the potential changes Feb 10, 2019
README.Rmd move logo to vignettes to prevent error on CRAN Jan 15, 2019
README.md Fix slack link Jan 19, 2019
cran-comments.md update DESCRIPTION, NEWS, and cran-comments Jan 26, 2019
karma.conf.js First cut, using webpack to build react-tools.js Feb 8, 2019
package.json merge master and resolve conflicts Feb 13, 2019
reactR.Rproj first working version Jun 24, 2016
webpack.config.js webpack: use mode = development Feb 11, 2019
yarn.lock merge master and resolve conflicts Feb 13, 2019

README.md

reactR reactR logo

CRAN_Status_Badge Travis-CI Build Status Slack Status

reactR provides a set of convenience functions for using 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 package.

Installation

You can install reactR from CRAN with install.packages("reactR"). For the development version, please use devtools as shown below.

# install.packages("devtools")
devtools::install_github("react-R/reactR")

Creating htmlwidgets with React Components

To wrap a React component as an htmlwidget, please see the tutorial htmlwidgets with reactR. Also, there are a variety of examples in the react-R Github organization.

Shiny?

Currently, htmlwidgets built with reactR work well in Shiny as outputs. In the next version we hope to have a mechanism for input in Shiny contexts.

Examples

library(reactR)
library(htmltools)

browsable(tagList(
  tags$div(id = "app"),
  tags$script(
  "
    ReactDOM.render(
      React.createElement(
        'h1',
        null,
        'Powered by React'
      ),
      document.getElementById('app')
    )
  "
  ),
  #add core-js first to work in RStudio Viewer
  html_dependency_corejs(),
  html_dependency_react()
))

reactR uses the V8 package if available to transform JSX and ES2015 code with babel.

library(reactR)
library(htmltools)

browsable(
  tagList(
    tags$div(id = "app"),
    tags$script(
      babel_transform('ReactDOM.render(<h1>Powered By React/JSX</h1>,document.getElementById("app"))')
    ),
    # add core-js shim first for React in RStudio Viewer
    html_dependency_corejs(),
    html_dependency_react()
  )
)

Contributing and Code of Conduct

We welcome contributors and would love your participation. Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by the terms.

Community

We operate a Slack workspace you are more than welcome to join.