Skip to content

Commit 5546b2a

Browse files
add very quick intro vignette
1 parent e3c5600 commit 5546b2a

File tree

3 files changed

+62
-2
lines changed

3 files changed

+62
-2
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22
.Rhistory
33
.RData
44
.Ruserdata
5+
inst/doc

DESCRIPTION

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ Authors@R: c(
1919
Maintainer: Kent Russell <[email protected]>
2020
Description: Make it easy to use 'react' in R with helper
2121
dependency functions, embedded 'Babel' transpiler,
22-
and examples.
22+
and examples. Please note the separate 'react'
23+
[BSD license](https://github.com/facebook/react/blob/master/LICENSE)
24+
when using 'reactR' and 'react' in your projects.
2325
URL: https://github.com/timelyportfolio/reactR
2426
BugReports: https://github.com/timelyportfolio/reactR/issues
2527
License: BSD_3_clause + file LICENSE
@@ -30,5 +32,7 @@ Suggests:
3032
htmlwidgets (>= 0.6.0),
3133
rmarkdown,
3234
shiny,
33-
V8
35+
V8,
36+
knitr
3437
RoxygenNote: 5.0.1
38+
VignetteBuilder: knitr

vignettes/intro_reactR.Rmd

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
---
2+
title: "Intro to reactR"
3+
author: "Kent Russell"
4+
date: "`r Sys.Date()`"
5+
output: rmarkdown::html_vignette
6+
vignette: >
7+
%\VignetteIndexEntry{Intro to reactR}
8+
%\VignetteEngine{knitr::rmarkdown}
9+
%\VignetteEncoding{UTF-8}
10+
---
11+
12+
## Why reactR?
13+
14+
[`react`](https://facebook.github.io/react/) has become incredibly popular, and the ecosystem around `react` is robust. `reactR` aims to allow `R` users to more easily incorporate `react` and `JSX`.
15+
16+
## Install
17+
18+
```
19+
install.packages("reactR")
20+
21+
# for the latest development version
22+
# install from Github
23+
# devtools::install_github("timelyportfolio/reactR")
24+
```
25+
26+
## Quick Example
27+
28+
Let's use `react` to render a simple `h1` HTML element below.
29+
30+
<div id="react-heading-here"></div>
31+
32+
```{r}
33+
library(reactR)
34+
library(htmltools)
35+
36+
attachDependencies(
37+
tags$script(
38+
"
39+
ReactDOM.render(
40+
React.createElement(
41+
'h1',
42+
null,
43+
'Powered by React'
44+
),
45+
document.getElementById('react-heading-here')
46+
)
47+
"
48+
),
49+
html_dependency_react()
50+
)
51+
```
52+
53+
## Using JSX
54+
55+
[`JSX`](https://facebook.github.io/react/docs/jsx-in-depth.html) helps ease some of the burden caused by `React.createElement`. `reactR` provides a `babel_transform()` function to use `JSX`. Hopefully, in the future, we can convince RStudio to modify `htmltools` to work directly with `JSX` (see [issue](https://github.com/rstudio/htmltools/pull/72)).

0 commit comments

Comments
 (0)