# [docsify-demo-box-react](https://github.com/njleonzhang/docsify-demo-box-react/)
> A plugin for [docsify](https://docsify.js.org/#/) to write React jsx demo with instant preview and jsfiddle integration
This plugin is for React. For Vue, please use [docsify-demo-box-vue](https://njleonzhang.github.io/docsify-demo-box-vue)
## Usage
1. import react and this plugin to docsify `index.html`
```html
```
2. Use this plugin as docsify plugin
```js
var jsResources = '\n' +
''
var cssResources = '@import url("//cdnjs.cloudflare.com/ajax/libs/normalize/7.0.0/normalize.min.css");'
var bootCode = 'var globalVariable = "leon"'
var globalVariable = "leon"
window.$docsify = {
name: 'docsify-demo-box-react',
repo: 'https://github.com/njleonzhang/docsify-demo-box-react',
plugins: [
DemoBoxReact.create(jsResources, cssResources, bootCode)
]
}
```
parameter of `create`:
* jsResources: javascript script will be added in `jsfiddle` html filed
* cssResources: css link will be added in `jsfiddle` css filed
* bootCode: javascript code you want to add before sample code in `jsfiddle` javascript filed, which is usually used to boot your library.
## sample
This doc is a sample, check the source [md](https://njleonzhang.github.io/docsify-demo-box-react/)
write the following code with tag `/*react*/`:
```jsx
Hello `world`
* a
* b
```
### special js link
In this sample, default js resource is defined as `react` and `react-dom` in `index.html`
```
// for preview
// for jsfiddle
var jsResources = '\n' +
''
```
If you want to add special js resource for some samples, you need add `script` link in `index.html` for preview.
At same time, use `jsResource` comment to add script for `jsfiffle`
```
/*jsResource jslink1 jslink2 ...*/
```
```jsx
/*react*/
/*jsResource https://unpkg.com/vue */
Hello world
```
Try in `jsfiddle`, you will find the following script is added to `jsfiddle` html area.
```
```