Create React App

Create React App

  • Getting started
  • Help
  • GitHub

›Development

Welcome

  • About The Docs

Getting Started

  • Getting Started
  • Folder Structure
  • Available Scripts
  • Browsers & Features
  • Updating To New Releases

Development

  • Editor Setup
  • Developing Components In Isolation
  • Analyzing Bundle Size
  • HTTPS In Development

Styles and Assets

  • Adding Stylesheets
  • Adding CSS Modules
  • Adding Sass Stylesheets
  • Post-Processing CSS
  • Adding Images, Fonts, And Files
  • Using The public Folder
  • Code Splitting

Building your App

  • Installing A Dependency
  • Importing A Component
  • Using Global Variables
  • Adding Bootstrap
  • Adding Flow
  • Adding Relay
  • Adding A Router
  • Environment Variables
  • Making A Progressive Web App

Testing

  • Running Tests
  • Debugging Tests

Back-End Integration

  • Proxying In Development
  • Fetching Data
  • Integrating With An API
  • Title & Meta Tags

Deployment

  • Deployment

Advanced Usage

  • Can I Use Decorators?
  • Pre-Rendering Static HTML
  • Advanced Configuration
  • Alternatives To Ejecting

Support

  • Troubleshooting

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 (source) or React Styleguidist (source) to your project. These are third-party tools that let you develop components and see all their states in isolation from your app.

Storybook for React Demo

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:

npm install -g @storybook/cli

Then, run the following command inside your app’s directory:

getstorybook

After that, follow the instructions on the screen.

Learn more about React Storybook:

  • Learn Storybook (tutorial)
  • Documentation
  • GitHub Repo
  • Snapshot Testing UI 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:

npm install --save react-styleguidist

Alternatively you may use yarn:

yarn add react-styleguidist

Then, add these scripts to your package.json:

   "scripts": {
+    "styleguide": "styleguidist server",
+    "styleguide:build": "styleguidist build",
     "start": "react-scripts start",

Then, run the following command inside your app’s directory:

npm run styleguide

After that, follow the instructions on the screen.

Learn more about React Styleguidist:

  • GitHub Repo
  • Documentation
← PreviousNext →
  • Getting Started with Storybook
  • Getting Started with Styleguidist
Create React App
Docs
Getting StartedDocumentation
Community
Stack OverflowSpectrumTwitter
More
GitHubStar
Facebook Open Source
Copyright © 2018 Facebook Inc.