Skip to content

Commit 2d111f5

Browse files
update document, adding Caveats section
1 parent 2ba8c02 commit 2d111f5

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

README.md

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,24 @@ Create React component from string
1111
- [Installation](#installation)
1212
- [Basic Example](#basic-example)
1313
- [Using Unknown Elements](#using-unknown-elements)
14+
- [Caveats](#caveats)
1415
- [Test](#test)
1516
- [License](#license)
1617

1718
<!-- tocstop -->
1819

1920
## Installation
2021

22+
First You need to load `@babel/standalone` in the browser :
23+
2124
```js
22-
$ npm install string-to-react-component --save
25+
<script src="https://unpkg.com/@babel/standalone/babel.min.js"></script>
2326
```
2427

25-
Also You need to load `@babel/standalone` in the browser :
28+
Then install `string-to-react-component` package
2629

2730
```js
28-
<script src="https://unpkg.com/@babel/standalone/babel.min.js"></script>
31+
$ npm install string-to-react-component --save
2932
```
3033

3134
## Basic Example
@@ -55,7 +58,7 @@ function App() {
5558

5659
- The given code inside the string should be a function.
5760

58-
- The given code is executed in the global scope, so imported objects from `react` package including `useState`, `useEffect`, ... are not accessible inside it and you should get them from `React` global variable :
61+
- The code inside the string is executed in the global scope, so imported objects from `react` package including `useState`, `useEffect`, ... are not accessible inside it and you should get them from `React` global variable :
5962

6063
```js
6164
import {useState} from 'react';
@@ -92,6 +95,12 @@ function App() {
9295
}
9396
```
9497

98+
## Caveats
99+
100+
This plugin does not use `eval` function, however, suffers from security and might expose you to XSS attacks
101+
102+
To prevent XSS attacks, You should sanitize user input before storing it.
103+
95104
## Test
96105

97106
```js

0 commit comments

Comments
 (0)