5 merge requests!12191Lim.Pisey.168:/Identified - We are currently investigating reports of missing build logs. The issue has been identified and a resolution is in progress. We will provide a further update when available.Mar 21, 09:02 UTC,!12853brikk,!5717Automatically extract project file structure from build bundle file,!5360Docusaurus,!5347Port user guide over
Usually, in an app, you have a lot of UI components, and each of them has many different states.
For an example, a simple button component could have following states:
- In a regular state, with a text label.
- In the disabled mode.
- In a loading state.
Usually, it’s hard to see these states without running a sample app or some examples.
Create React App doesn’t include any tools for this by default, but you can easily add [Storybook for React](https://storybook.js.org)([source](https://github.com/storybooks/storybook)) or [React Styleguidist](https://react-styleguidist.js.org/)([source](https://github.com/styleguidist/react-styleguidist)) to your project. **These are third-party tools that let you develop components and see all their states in isolation from your app**.

You can also deploy your Storybook or style guide as a static app. This way, everyone in your team can view and review different states of UI components without starting a backend server or creating an account in your app.
### Getting Started with Storybook
Storybook is a development environment for React UI components. It allows you to browse a component library, view the different states of each component, and interactively develop and test components.
First, install the following npm package globally:
```sh
npm install-g @storybook/cli
```
Then, run the following command inside your app’s directory:
```sh
getstorybook
```
After that, follow the instructions on the screen.
-[Snapshot Testing UI](https://github.com/storybooks/storybook/tree/master/addons/storyshots) with Storybook + addon/storyshot
### Getting Started with Styleguidist
Styleguidist combines a style guide, where all your components are presented on a single page with their props documentation and usage examples, with an environment for developing components in isolation, similar to Storybook. In Styleguidist you write examples in Markdown, where each code snippet is rendered as a live editable playground.
First, install Styleguidist:
```sh
npm install--save react-styleguidist
```
Alternatively you may use `yarn`:
```sh
yarn add react-styleguidist
```
Then, add these scripts to your `package.json`:
```diff
"scripts": {
+ "styleguide": "styleguidist server",
+ "styleguide:build": "styleguidist build",
"start": "react-scripts start",
```
Then, run the following command inside your app’s directory:
```sh
npm run styleguide
```
After that, follow the instructions on the screen.
@@ -916,87 +913,6 @@ Similarly to the previous section, you can leave some placeholders in the HTML t
Then, on the server, you can replace `__SERVER_DATA__` with a JSON of real data right before sending the response. The client code can then read `window.SERVER_DATA` to use it. **Make sure to [sanitize the JSON before sending it to the client](https://medium.com/node-security/the-most-common-xss-vulnerability-in-react-js-applications-2bdffbcc1fa0) as it makes your app vulnerable to XSS attacks.**
## Developing Components in Isolation
Usually, in an app, you have a lot of UI components, and each of them has many different states.
For an example, a simple button component could have following states:
- In a regular state, with a text label.
- In the disabled mode.
- In a loading state.
Usually, it’s hard to see these states without running a sample app or some examples.
Create React App doesn’t include any tools for this by default, but you can easily add [Storybook for React](https://storybook.js.org)([source](https://github.com/storybooks/storybook)) or [React Styleguidist](https://react-styleguidist.js.org/)([source](https://github.com/styleguidist/react-styleguidist)) to your project. **These are third-party tools that let you develop components and see all their states in isolation from your app**.

You can also deploy your Storybook or style guide as a static app. This way, everyone in your team can view and review different states of UI components without starting a backend server or creating an account in your app.
### Getting Started with Storybook
Storybook is a development environment for React UI components. It allows you to browse a component library, view the different states of each component, and interactively develop and test components.
First, install the following npm package globally:
```sh
npm install-g @storybook/cli
```
Then, run the following command inside your app’s directory:
```sh
getstorybook
```
After that, follow the instructions on the screen.
-[Snapshot Testing UI](https://github.com/storybooks/storybook/tree/master/addons/storyshots) with Storybook + addon/storyshot
### Getting Started with Styleguidist
Styleguidist combines a style guide, where all your components are presented on a single page with their props documentation and usage examples, with an environment for developing components in isolation, similar to Storybook. In Styleguidist you write examples in Markdown, where each code snippet is rendered as a live editable playground.
First, install Styleguidist:
```sh
npm install--save react-styleguidist
```
Alternatively you may use `yarn`:
```sh
yarn add react-styleguidist
```
Then, add these scripts to your `package.json`:
```diff
"scripts": {
+ "styleguide": "styleguidist server",
+ "styleguide:build": "styleguidist build",
"start": "react-scripts start",
```
Then, run the following command inside your app’s directory:
```sh
npm run styleguide
```
After that, follow the instructions on the screen.