{"id":31766185,"url":"https://github.com/nomangul/react-course","last_synced_at":"2025-10-10T00:29:52.693Z","repository":{"id":52452331,"uuid":"147685819","full_name":"NomanGul/React-Course","owner":"NomanGul","description":"For React Course | Practice Coding React","archived":false,"fork":false,"pushed_at":"2021-04-28T21:57:27.000Z","size":578,"stargazers_count":1,"open_issues_count":5,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-12-18T06:22:59.803Z","etag":null,"topics":["noman-gul","react-course","reactjs"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/NomanGul.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-09-06T14:25:06.000Z","updated_at":"2018-09-07T10:14:12.000Z","dependencies_parsed_at":"2022-08-18T19:11:15.960Z","dependency_job_id":null,"html_url":"https://github.com/NomanGul/React-Course","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/NomanGul/React-Course","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NomanGul%2FReact-Course","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NomanGul%2FReact-Course/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NomanGul%2FReact-Course/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NomanGul%2FReact-Course/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/NomanGul","download_url":"https://codeload.github.com/NomanGul/React-Course/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NomanGul%2FReact-Course/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279002359,"owners_count":26083356,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-09T02:00:07.460Z","response_time":59,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["noman-gul","react-course","reactjs"],"created_at":"2025-10-10T00:29:35.202Z","updated_at":"2025-10-10T00:29:52.678Z","avatar_url":"https://github.com/NomanGul.png","language":"JavaScript","readme":"This project was bootstrapped with [Create React App](https://github.com/facebookincubator/create-react-app).\n\nBelow you will find some information on how to perform common tasks.\u003cbr\u003e\nYou can find the most recent version of this guide [here](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md).\n\n## Table of Contents\n\n- [Updating to New Releases](#updating-to-new-releases)\n- [Sending Feedback](#sending-feedback)\n- [Folder Structure](#folder-structure)\n- [Available Scripts](#available-scripts)\n  - [npm start](#npm-start)\n  - [npm test](#npm-test)\n  - [npm run build](#npm-run-build)\n  - [npm run eject](#npm-run-eject)\n- [Supported Browsers](#supported-browsers)\n- [Supported Language Features and Polyfills](#supported-language-features-and-polyfills)\n- [Syntax Highlighting in the Editor](#syntax-highlighting-in-the-editor)\n- [Displaying Lint Output in the Editor](#displaying-lint-output-in-the-editor)\n- [Debugging in the Editor](#debugging-in-the-editor)\n- [Formatting Code Automatically](#formatting-code-automatically)\n- [Changing the Page `\u003ctitle\u003e`](#changing-the-page-title)\n- [Installing a Dependency](#installing-a-dependency)\n- [Importing a Component](#importing-a-component)\n- [Code Splitting](#code-splitting)\n- [Adding a Stylesheet](#adding-a-stylesheet)\n- [Post-Processing CSS](#post-processing-css)\n- [Adding a CSS Preprocessor (Sass, Less etc.)](#adding-a-css-preprocessor-sass-less-etc)\n- [Adding Images, Fonts, and Files](#adding-images-fonts-and-files)\n- [Using the `public` Folder](#using-the-public-folder)\n  - [Changing the HTML](#changing-the-html)\n  - [Adding Assets Outside of the Module System](#adding-assets-outside-of-the-module-system)\n  - [When to Use the `public` Folder](#when-to-use-the-public-folder)\n- [Using Global Variables](#using-global-variables)\n- [Adding Bootstrap](#adding-bootstrap)\n  - [Using a Custom Theme](#using-a-custom-theme)\n- [Adding Flow](#adding-flow)\n- [Adding a Router](#adding-a-router)\n- [Adding Custom Environment Variables](#adding-custom-environment-variables)\n  - [Referencing Environment Variables in the HTML](#referencing-environment-variables-in-the-html)\n  - [Adding Temporary Environment Variables In Your Shell](#adding-temporary-environment-variables-in-your-shell)\n  - [Adding Development Environment Variables In `.env`](#adding-development-environment-variables-in-env)\n- [Can I Use Decorators?](#can-i-use-decorators)\n- [Fetching Data with AJAX Requests](#fetching-data-with-ajax-requests)\n- [Integrating with an API Backend](#integrating-with-an-api-backend)\n  - [Node](#node)\n  - [Ruby on Rails](#ruby-on-rails)\n- [Proxying API Requests in Development](#proxying-api-requests-in-development)\n  - [\"Invalid Host Header\" Errors After Configuring Proxy](#invalid-host-header-errors-after-configuring-proxy)\n  - [Configuring the Proxy Manually](#configuring-the-proxy-manually)\n  - [Configuring a WebSocket Proxy](#configuring-a-websocket-proxy)\n- [Using HTTPS in Development](#using-https-in-development)\n- [Generating Dynamic `\u003cmeta\u003e` Tags on the Server](#generating-dynamic-meta-tags-on-the-server)\n- [Pre-Rendering into Static HTML Files](#pre-rendering-into-static-html-files)\n- [Injecting Data from the Server into the Page](#injecting-data-from-the-server-into-the-page)\n- [Running Tests](#running-tests)\n  - [Filename Conventions](#filename-conventions)\n  - [Command Line Interface](#command-line-interface)\n  - [Version Control Integration](#version-control-integration)\n  - [Writing Tests](#writing-tests)\n  - [Testing Components](#testing-components)\n  - [Using Third Party Assertion Libraries](#using-third-party-assertion-libraries)\n  - [Initializing Test Environment](#initializing-test-environment)\n  - [Focusing and Excluding Tests](#focusing-and-excluding-tests)\n  - [Coverage Reporting](#coverage-reporting)\n  - [Continuous Integration](#continuous-integration)\n  - [Disabling jsdom](#disabling-jsdom)\n  - [Snapshot Testing](#snapshot-testing)\n  - [Editor Integration](#editor-integration)\n- [Debugging Tests](#debugging-tests)\n  - [Debugging Tests in Chrome](#debugging-tests-in-chrome)\n  - [Debugging Tests in Visual Studio Code](#debugging-tests-in-visual-studio-code)\n- [Developing Components in Isolation](#developing-components-in-isolation)\n  - [Getting Started with Storybook](#getting-started-with-storybook)\n  - [Getting Started with Styleguidist](#getting-started-with-styleguidist)\n- [Publishing Components to npm](#publishing-components-to-npm)\n- [Making a Progressive Web App](#making-a-progressive-web-app)\n  - [Opting Out of Caching](#opting-out-of-caching)\n  - [Offline-First Considerations](#offline-first-considerations)\n  - [Progressive Web App Metadata](#progressive-web-app-metadata)\n- [Analyzing the Bundle Size](#analyzing-the-bundle-size)\n- [Deployment](#deployment)\n  - [Static Server](#static-server)\n  - [Other Solutions](#other-solutions)\n  - [Serving Apps with Client-Side Routing](#serving-apps-with-client-side-routing)\n  - [Building for Relative Paths](#building-for-relative-paths)\n  - [Azure](#azure)\n  - [Firebase](#firebase)\n  - [GitHub Pages](#github-pages)\n  - [Heroku](#heroku)\n  - [Netlify](#netlify)\n  - [Now](#now)\n  - [S3 and CloudFront](#s3-and-cloudfront)\n  - [Surge](#surge)\n- [Advanced Configuration](#advanced-configuration)\n- [Troubleshooting](#troubleshooting)\n  - [`npm start` doesn’t detect changes](#npm-start-doesnt-detect-changes)\n  - [`npm test` hangs on macOS Sierra](#npm-test-hangs-on-macos-sierra)\n  - [`npm run build` exits too early](#npm-run-build-exits-too-early)\n  - [`npm run build` fails on Heroku](#npm-run-build-fails-on-heroku)\n  - [`npm run build` fails to minify](#npm-run-build-fails-to-minify)\n  - [Moment.js locales are missing](#momentjs-locales-are-missing)\n- [Alternatives to Ejecting](#alternatives-to-ejecting)\n- [Something Missing?](#something-missing)\n\n## Updating to New Releases\n\nCreate React App is divided into two packages:\n\n* `create-react-app` is a global command-line utility that you use to create new projects.\n* `react-scripts` is a development dependency in the generated projects (including this one).\n\nYou almost never need to update `create-react-app` itself: it delegates all the setup to `react-scripts`.\n\nWhen you run `create-react-app`, it always creates the project with the latest version of `react-scripts` so you’ll get all the new features and improvements in newly created apps automatically.\n\nTo update an existing project to a new version of `react-scripts`, [open the changelog](https://github.com/facebookincubator/create-react-app/blob/master/CHANGELOG.md), find the version you’re currently on (check `package.json` in this folder if you’re not sure), and apply the migration instructions for the newer versions.\n\nIn most cases bumping the `react-scripts` version in `package.json` and running `npm install` in this folder should be enough, but it’s good to consult the [changelog](https://github.com/facebookincubator/create-react-app/blob/master/CHANGELOG.md) for potential breaking changes.\n\nWe commit to keeping the breaking changes minimal so you can upgrade `react-scripts` painlessly.\n\n## Sending Feedback\n\nWe are always open to [your feedback](https://github.com/facebookincubator/create-react-app/issues).\n\n## Folder Structure\n\nAfter creation, your project should look like this:\n\n```\nmy-app/\n  README.md\n  node_modules/\n  package.json\n  public/\n    index.html\n    favicon.ico\n  src/\n    App.css\n    App.js\n    App.test.js\n    index.css\n    index.js\n    logo.svg\n```\n\nFor the project to build, **these files must exist with exact filenames**:\n\n* `public/index.html` is the page template;\n* `src/index.js` is the JavaScript entry point.\n\nYou can delete or rename the other files.\n\nYou may create subdirectories inside `src`. For faster rebuilds, only files inside `src` are processed by Webpack.\u003cbr\u003e\nYou need to **put any JS and CSS files inside `src`**, otherwise Webpack won’t see them.\n\nOnly files inside `public` can be used from `public/index.html`.\u003cbr\u003e\nRead instructions below for using assets from JavaScript and HTML.\n\nYou can, however, create more top-level directories.\u003cbr\u003e\nThey will not be included in the production build so you can use them for things like documentation.\n\n## Available Scripts\n\nIn the project directory, you can run:\n\n### `npm start`\n\nRuns the app in the development mode.\u003cbr\u003e\nOpen [http://localhost:3000](http://localhost:3000) to view it in the browser.\n\nThe page will reload if you make edits.\u003cbr\u003e\nYou will also see any lint errors in the console.\n\n### `npm test`\n\nLaunches the test runner in the interactive watch mode.\u003cbr\u003e\nSee the section about [running tests](#running-tests) for more information.\n\n### `npm run build`\n\nBuilds the app for production to the `build` folder.\u003cbr\u003e\nIt correctly bundles React in production mode and optimizes the build for the best performance.\n\nThe build is minified and the filenames include the hashes.\u003cbr\u003e\nYour app is ready to be deployed!\n\nSee the section about [deployment](#deployment) for more information.\n\n### `npm run eject`\n\n**Note: this is a one-way operation. Once you `eject`, you can’t go back!**\n\nIf you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.\n\nInstead, it will copy all the configuration files and the transitive dependencies (Webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own.\n\nYou don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it.\n\n## Supported Browsers\n\nBy default, the generated project uses the latest version of React.\n\nYou can refer [to the React documentation](https://reactjs.org/docs/react-dom.html#browser-support) for more information about supported browsers.\n\n## Supported Language Features and Polyfills\n\nThis project supports a superset of the latest JavaScript standard.\u003cbr\u003e\nIn addition to [ES6](https://github.com/lukehoban/es6features) syntax features, it also supports:\n\n* [Exponentiation Operator](https://github.com/rwaldron/exponentiation-operator) (ES2016).\n* [Async/await](https://github.com/tc39/ecmascript-asyncawait) (ES2017).\n* [Object Rest/Spread Properties](https://github.com/sebmarkbage/ecmascript-rest-spread) (stage 3 proposal).\n* [Dynamic import()](https://github.com/tc39/proposal-dynamic-import) (stage 3 proposal)\n* [Class Fields and Static Properties](https://github.com/tc39/proposal-class-public-fields) (part of stage 3 proposal).\n* [JSX](https://facebook.github.io/react/docs/introducing-jsx.html) and [Flow](https://flowtype.org/) syntax.\n\nLearn more about [different proposal stages](https://babeljs.io/docs/plugins/#presets-stage-x-experimental-presets-).\n\nWhile we recommend using experimental proposals with some caution, Facebook heavily uses these features in the product code, so we intend to provide [codemods](https://medium.com/@cpojer/effective-javascript-codemods-5a6686bb46fb) if any of these proposals change in the future.\n\nNote that **the project only includes a few ES6 [polyfills](https://en.wikipedia.org/wiki/Polyfill)**:\n\n* [`Object.assign()`](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Object/assign) via [`object-assign`](https://github.com/sindresorhus/object-assign).\n* [`Promise`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) via [`promise`](https://github.com/then/promise).\n* [`fetch()`](https://developer.mozilla.org/en/docs/Web/API/Fetch_API) via [`whatwg-fetch`](https://github.com/github/fetch).\n\nIf you use any other ES6+ features that need **runtime support** (such as `Array.from()` or `Symbol`), make sure you are including the appropriate polyfills manually, or that the browsers you are targeting already support them.\n\nAlso note that using some newer syntax features like `for...of` or `[...nonArrayValue]` causes Babel to emit code that depends on ES6 runtime features and might not work without a polyfill. When in doubt, use [Babel REPL](https://babeljs.io/repl/) to see what any specific syntax compiles down to.\n\n## Syntax Highlighting in the Editor\n\nTo configure the syntax highlighting in your favorite text editor, head to the [relevant Babel documentation page](https://babeljs.io/docs/editors) and follow the instructions. Some of the most popular editors are covered.\n\n## Displaying Lint Output in the Editor\n\n\u003eNote: this feature is available with `react-scripts@0.2.0` and higher.\u003cbr\u003e\n\u003eIt also only works with npm 3 or higher.\n\nSome editors, including Sublime Text, Atom, and Visual Studio Code, provide plugins for ESLint.\n\nThey are not required for linting. You should see the linter output right in your terminal as well as the browser console. However, if you prefer the lint results to appear right in your editor, there are some extra steps you can do.\n\nYou would need to install an ESLint plugin for your editor first. Then, add a file called `.eslintrc` to the project root:\n\n```js\n{\n  \"extends\": \"react-app\"\n}\n```\n\nNow your editor should report the linting warnings.\n\nNote that even if you edit your `.eslintrc` file further, these changes will **only affect the editor integration**. They won’t affect the terminal and in-browser lint output. This is because Create React App intentionally provides a minimal set of rules that find common mistakes.\n\nIf you want to enforce a coding style for your project, consider using [Prettier](https://github.com/jlongster/prettier) instead of ESLint style rules.\n\n## Debugging in the Editor\n\n**This feature is currently only supported by [Visual Studio Code](https://code.visualstudio.com) and [WebStorm](https://www.jetbrains.com/webstorm/).**\n\nVisual Studio Code and WebStorm support debugging out of the box with Create React App. This enables you as a developer to write and debug your React code without leaving the editor, and most importantly it enables you to have a continuous development workflow, where context switching is minimal, as you don’t have to switch between tools.\n\n### Visual Studio Code\n\nYou would need to have the latest version of [VS Code](https://code.visualstudio.com) and VS Code [Chrome Debugger Extension](https://marketplace.visualstudio.com/items?itemName=msjsdiag.debugger-for-chrome) installed.\n\nThen add the block below to your `launch.json` file and put it inside the `.vscode` folder in your app’s root directory.\n\n```json\n{\n  \"version\": \"0.2.0\",\n  \"configurations\": [{\n    \"name\": \"Chrome\",\n    \"type\": \"chrome\",\n    \"request\": \"launch\",\n    \"url\": \"http://localhost:3000\",\n    \"webRoot\": \"${workspaceRoot}/src\",\n    \"sourceMapPathOverrides\": {\n      \"webpack:///src/*\": \"${webRoot}/*\"\n    }\n  }]\n}\n```\n\u003eNote: the URL may be different if you've made adjustments via the [HOST or PORT environment variables](#advanced-configuration).\n\nStart your app by running `npm start`, and start debugging in VS Code by pressing `F5` or by clicking the green debug icon. You can now write code, set breakpoints, make changes to the code, and debug your newly modified code—all from your editor.\n\nHaving problems with VS Code Debugging? Please see their [troubleshooting guide](https://github.com/Microsoft/vscode-chrome-debug/blob/master/README.md#troubleshooting).\n\n### WebStorm\n\nYou would need to have [WebStorm](https://www.jetbrains.com/webstorm/) and [JetBrains IDE Support](https://chrome.google.com/webstore/detail/jetbrains-ide-support/hmhgeddbohgjknpmjagkdomcpobmllji) Chrome extension installed.\n\nIn the WebStorm menu `Run` select `Edit Configurations...`. Then click `+` and select `JavaScript Debug`. Paste `http://localhost:3000` into the URL field and save the configuration.\n\n\u003eNote: the URL may be different if you've made adjustments via the [HOST or PORT environment variables](#advanced-configuration).\n\nStart your app by running `npm start`, then press `^D` on macOS or `F9` on Windows and Linux or click the green debug icon to start debugging in WebStorm.\n\nThe same way you can debug your application in IntelliJ IDEA Ultimate, PhpStorm, PyCharm Pro, and RubyMine. \n\n## Formatting Code Automatically\n\nPrettier is an opinionated code formatter with support for JavaScript, CSS and JSON. With Prettier you can format the code you write automatically to ensure a code style within your project. See the [Prettier's GitHub page](https://github.com/prettier/prettier) for more information, and look at this [page to see it in action](https://prettier.github.io/prettier/).\n\nTo format our code whenever we make a commit in git, we need to install the following dependencies:\n\n```sh\nnpm install --save husky lint-staged prettier\n```\n\nAlternatively you may use `yarn`:\n\n```sh\nyarn add husky lint-staged prettier\n```\n\n* `husky` makes it easy to use githooks as if they are npm scripts.\n* `lint-staged` allows us to run scripts on staged files in git. See this [blog post about lint-staged to learn more about it](https://medium.com/@okonetchnikov/make-linting-great-again-f3890e1ad6b8).\n* `prettier` is the JavaScript formatter we will run before commits.\n\nNow we can make sure every file is formatted correctly by adding a few lines to the `package.json` in the project root.\n\nAdd the following line to `scripts` section:\n\n```diff\n  \"scripts\": {\n+   \"precommit\": \"lint-staged\",\n    \"start\": \"react-scripts start\",\n    \"build\": \"react-scripts build\",\n```\n\nNext we add a 'lint-staged' field to the `package.json`, for example:\n\n```diff\n  \"dependencies\": {\n    // ...\n  },\n+ \"lint-staged\": {\n+   \"src/**/*.{js,jsx,json,css}\": [\n+     \"prettier --single-quote --write\",\n+     \"git add\"\n+   ]\n+ },\n  \"scripts\": {\n```\n\nNow, whenever you make a commit, Prettier will format the changed files automatically. You can also run `./node_modules/.bin/prettier --single-quote --write \"src/**/*.{js,jsx,json,css}\"` to format your entire project for the first time.\n\nNext you might want to integrate Prettier in your favorite editor. Read the section on [Editor Integration](https://prettier.io/docs/en/editors.html) on the Prettier GitHub page.\n\n## Changing the Page `\u003ctitle\u003e`\n\nYou can find the source HTML file in the `public` folder of the generated project. You may edit the `\u003ctitle\u003e` tag in it to change the title from “React App” to anything else.\n\nNote that normally you wouldn’t edit files in the `public` folder very often. For example, [adding a stylesheet](#adding-a-stylesheet) is done without touching the HTML.\n\nIf you need to dynamically update the page title based on the content, you can use the browser [`document.title`](https://developer.mozilla.org/en-US/docs/Web/API/Document/title) API. For more complex scenarios when you want to change the title from React components, you can use [React Helmet](https://github.com/nfl/react-helmet), a third party library.\n\nIf you use a custom server for your app in production and want to modify the title before it gets sent to the browser, you can follow advice in [this section](#generating-dynamic-meta-tags-on-the-server). Alternatively, you can pre-build each page as a static HTML file which then loads the JavaScript bundle, which is covered [here](#pre-rendering-into-static-html-files).\n\n## Installing a Dependency\n\nThe generated project includes React and ReactDOM as dependencies. It also includes a set of scripts used by Create React App as a development dependency. You may install other dependencies (for example, React Router) with `npm`:\n\n```sh\nnpm install --save react-router\n```\n\nAlternatively you may use `yarn`:\n\n```sh\nyarn add react-router\n```\n\nThis works for any library, not just `react-router`.\n\n## Importing a Component\n\nThis project setup supports ES6 modules thanks to Babel.\u003cbr\u003e\nWhile you can still use `require()` and `module.exports`, we encourage you to use [`import` and `export`](http://exploringjs.com/es6/ch_modules.html) instead.\n\nFor example:\n\n### `Button.js`\n\n```js\nimport React, { Component } from 'react';\n\nclass Button extends Component {\n  render() {\n    // ...\n  }\n}\n\nexport default Button; // Don’t forget to use export default!\n```\n\n### `DangerButton.js`\n\n\n```js\nimport React, { Component } from 'react';\nimport Button from './Button'; // Import a component from another file\n\nclass DangerButton extends Component {\n  render() {\n    return \u003cButton color=\"red\" /\u003e;\n  }\n}\n\nexport default DangerButton;\n```\n\nBe aware of the [difference between default and named exports](http://stackoverflow.com/questions/36795819/react-native-es-6-when-should-i-use-curly-braces-for-import/36796281#36796281). It is a common source of mistakes.\n\nWe suggest that you stick to using default imports and exports when a module only exports a single thing (for example, a component). That’s what you get when you use `export default Button` and `import Button from './Button'`.\n\nNamed exports are useful for utility modules that export several functions. A module may have at most one default export and as many named exports as you like.\n\nLearn more about ES6 modules:\n\n* [When to use the curly braces?](http://stackoverflow.com/questions/36795819/react-native-es-6-when-should-i-use-curly-braces-for-import/36796281#36796281)\n* [Exploring ES6: Modules](http://exploringjs.com/es6/ch_modules.html)\n* [Understanding ES6: Modules](https://leanpub.com/understandinges6/read#leanpub-auto-encapsulating-code-with-modules)\n\n## Code Splitting\n\nInstead of downloading the entire app before users can use it, code splitting allows you to split your code into small chunks which you can then load on demand.\n\nThis project setup supports code splitting via [dynamic `import()`](http://2ality.com/2017/01/import-operator.html#loading-code-on-demand). Its [proposal](https://github.com/tc39/proposal-dynamic-import) is in stage 3. The `import()` function-like form takes the module name as an argument and returns a [`Promise`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) which always resolves to the namespace object of the module.\n\nHere is an example:\n\n### `moduleA.js`\n\n```js\nconst moduleA = 'Hello';\n\nexport { moduleA };\n```\n### `App.js`\n\n```js\nimport React, { Component } from 'react';\n\nclass App extends Component {\n  handleClick = () =\u003e {\n    import('./moduleA')\n      .then(({ moduleA }) =\u003e {\n        // Use moduleA\n      })\n      .catch(err =\u003e {\n        // Handle failure\n      });\n  };\n\n  render() {\n    return (\n      \u003cdiv\u003e\n        \u003cbutton onClick={this.handleClick}\u003eLoad\u003c/button\u003e\n      \u003c/div\u003e\n    );\n  }\n}\n\nexport default App;\n```\n\nThis will make `moduleA.js` and all its unique dependencies as a separate chunk that only loads after the user clicks the 'Load' button.\n\nYou can also use it with `async` / `await` syntax if you prefer it.\n\n### With React Router\n\nIf you are using React Router check out [this tutorial](http://serverless-stack.com/chapters/code-splitting-in-create-react-app.html) on how to use code splitting with it. You can find the companion GitHub repository [here](https://github.com/AnomalyInnovations/serverless-stack-demo-client/tree/code-splitting-in-create-react-app).\n\nAlso check out the [Code Splitting](https://reactjs.org/docs/code-splitting.html) section in React documentation.\n\n## Adding a Stylesheet\n\nThis project setup uses [Webpack](https://webpack.js.org/) for handling all assets. Webpack offers a custom way of “extending” the concept of `import` beyond JavaScript. To express that a JavaScript file depends on a CSS file, you need to **import the CSS from the JavaScript file**:\n\n### `Button.css`\n\n```css\n.Button {\n  padding: 20px;\n}\n```\n\n### `Button.js`\n\n```js\nimport React, { Component } from 'react';\nimport './Button.css'; // Tell Webpack that Button.js uses these styles\n\nclass Button extends Component {\n  render() {\n    // You can use them as regular CSS styles\n    return \u003cdiv className=\"Button\" /\u003e;\n  }\n}\n```\n\n**This is not required for React** but many people find this feature convenient. You can read about the benefits of this approach [here](https://medium.com/seek-ui-engineering/block-element-modifying-your-javascript-components-d7f99fcab52b). However you should be aware that this makes your code less portable to other build tools and environments than Webpack.\n\nIn development, expressing dependencies this way allows your styles to be reloaded on the fly as you edit them. In production, all CSS files will be concatenated into a single minified `.css` file in the build output.\n\nIf you are concerned about using Webpack-specific semantics, you can put all your CSS right into `src/index.css`. It would still be imported from `src/index.js`, but you could always remove that import if you later migrate to a different build tool.\n\n## Post-Processing CSS\n\nThis project setup minifies your CSS and adds vendor prefixes to it automatically through [Autoprefixer](https://github.com/postcss/autoprefixer) so you don’t need to worry about it.\n\nFor example, this:\n\n```css\n.App {\n  display: flex;\n  flex-direction: row;\n  align-items: center;\n}\n```\n\nbecomes this:\n\n```css\n.App {\n  display: -webkit-box;\n  display: -ms-flexbox;\n  display: flex;\n  -webkit-box-orient: horizontal;\n  -webkit-box-direction: normal;\n      -ms-flex-direction: row;\n          flex-direction: row;\n  -webkit-box-align: center;\n      -ms-flex-align: center;\n          align-items: center;\n}\n```\n\nIf you need to disable autoprefixing for some reason, [follow this section](https://github.com/postcss/autoprefixer#disabling).\n\n## Adding a CSS Preprocessor (Sass, Less etc.)\n\nGenerally, we recommend that you don’t reuse the same CSS classes across different components. For example, instead of using a `.Button` CSS class in `\u003cAcceptButton\u003e` and `\u003cRejectButton\u003e` components, we recommend creating a `\u003cButton\u003e` component with its own `.Button` styles, that both `\u003cAcceptButton\u003e` and `\u003cRejectButton\u003e` can render (but [not inherit](https://facebook.github.io/react/docs/composition-vs-inheritance.html)).\n\nFollowing this rule often makes CSS preprocessors less useful, as features like mixins and nesting are replaced by component composition. You can, however, integrate a CSS preprocessor if you find it valuable. In this walkthrough, we will be using Sass, but you can also use Less, or another alternative.\n\nFirst, let’s install the command-line interface for Sass:\n\n```sh\nnpm install --save node-sass-chokidar\n```\n\nAlternatively you may use `yarn`:\n\n```sh\nyarn add node-sass-chokidar\n```\n\nThen in `package.json`, add the following lines to `scripts`:\n\n```diff\n   \"scripts\": {\n+    \"build-css\": \"node-sass-chokidar src/ -o src/\",\n+    \"watch-css\": \"npm run build-css \u0026\u0026 node-sass-chokidar src/ -o src/ --watch --recursive\",\n     \"start\": \"react-scripts start\",\n     \"build\": \"react-scripts build\",\n     \"test\": \"react-scripts test --env=jsdom\",\n```\n\n\u003eNote: To use a different preprocessor, replace `build-css` and `watch-css` commands according to your preprocessor’s documentation.\n\nNow you can rename `src/App.css` to `src/App.scss` and run `npm run watch-css`. The watcher will find every Sass file in `src` subdirectories, and create a corresponding CSS file next to it, in our case overwriting `src/App.css`. Since `src/App.js` still imports `src/App.css`, the styles become a part of your application. You can now edit `src/App.scss`, and `src/App.css` will be regenerated.\n\nTo share variables between Sass files, you can use Sass imports. For example, `src/App.scss` and other component style files could include `@import \"./shared.scss\";` with variable definitions.\n\nTo enable importing files without using relative paths, you can add the  `--include-path` option to the command in `package.json`.\n\n```\n\"build-css\": \"node-sass-chokidar --include-path ./src --include-path ./node_modules src/ -o src/\",\n\"watch-css\": \"npm run build-css \u0026\u0026 node-sass-chokidar --include-path ./src --include-path ./node_modules src/ -o src/ --watch --recursive\",\n```\n\nThis will allow you to do imports like\n\n```scss\n@import 'styles/_colors.scss'; // assuming a styles directory under src/\n@import 'nprogress/nprogress'; // importing a css file from the nprogress node module\n```\n\nAt this point you might want to remove all CSS files from the source control, and add `src/**/*.css` to your `.gitignore` file. It is generally a good practice to keep the build products outside of the source control.\n\nAs a final step, you may find it convenient to run `watch-css` automatically with `npm start`, and run `build-css` as a part of `npm run build`. You can use the `\u0026\u0026` operator to execute two scripts sequentially. However, there is no cross-platform way to run two scripts in parallel, so we will install a package for this:\n\n```sh\nnpm install --save npm-run-all\n```\n\nAlternatively you may use `yarn`:\n\n```sh\nyarn add npm-run-all\n```\n\nThen we can change `start` and `build` scripts to include the CSS preprocessor commands:\n\n```diff\n   \"scripts\": {\n     \"build-css\": \"node-sass-chokidar src/ -o src/\",\n     \"watch-css\": \"npm run build-css \u0026\u0026 node-sass-chokidar src/ -o src/ --watch --recursive\",\n-    \"start\": \"react-scripts start\",\n-    \"build\": \"react-scripts build\",\n+    \"start-js\": \"react-scripts start\",\n+    \"start\": \"npm-run-all -p watch-css start-js\",\n+    \"build-js\": \"react-scripts build\",\n+    \"build\": \"npm-run-all build-css build-js\",\n     \"test\": \"react-scripts test --env=jsdom\",\n     \"eject\": \"react-scripts eject\"\n   }\n```\n\nNow running `npm start` and `npm run build` also builds Sass files.\n\n**Why `node-sass-chokidar`?**\n\n`node-sass` has been reported as having the following issues:\n\n- `node-sass --watch` has been reported to have *performance issues* in certain conditions when used in a virtual machine or with docker.\n\n- Infinite styles compiling [#1939](https://github.com/facebookincubator/create-react-app/issues/1939)\n\n- `node-sass` has been reported as having issues with detecting new files in a directory [#1891](https://github.com/sass/node-sass/issues/1891)\n\n `node-sass-chokidar` is used here as it addresses these issues.\n\n## Adding Images, Fonts, and Files\n\nWith Webpack, using static assets like images and fonts works similarly to CSS.\n\nYou can **`import` a file right in a JavaScript module**. This tells Webpack to include that file in the bundle. Unlike CSS imports, importing a file gives you a string value. This value is the final path you can reference in your code, e.g. as the `src` attribute of an image or the `href` of a link to a PDF.\n\nTo reduce the number of requests to the server, importing images that are less than 10,000 bytes returns a [data URI](https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URIs) instead of a path. This applies to the following file extensions: bmp, gif, jpg, jpeg, and png. SVG files are excluded due to [#1153](https://github.com/facebookincubator/create-react-app/issues/1153).\n\nHere is an example:\n\n```js\nimport React from 'react';\nimport logo from './logo.png'; // Tell Webpack this JS file uses this image\n\nconsole.log(logo); // /logo.84287d09.png\n\nfunction Header() {\n  // Import result is the URL of your image\n  return \u003cimg src={logo} alt=\"Logo\" /\u003e;\n}\n\nexport default Header;\n```\n\nThis ensures that when the project is built, Webpack will correctly move the images into the build folder, and provide us with correct paths.\n\nThis works in CSS too:\n\n```css\n.Logo {\n  background-image: url(./logo.png);\n}\n```\n\nWebpack finds all relative module references in CSS (they start with `./`) and replaces them with the final paths from the compiled bundle. If you make a typo or accidentally delete an important file, you will see a compilation error, just like when you import a non-existent JavaScript module. The final filenames in the compiled bundle are generated by Webpack from content hashes. If the file content changes in the future, Webpack will give it a different name in production so you don’t need to worry about long-term caching of assets.\n\nPlease be advised that this is also a custom feature of Webpack.\n\n**It is not required for React** but many people enjoy it (and React Native uses a similar mechanism for images).\u003cbr\u003e\nAn alternative way of handling static assets is described in the next section.\n\n## Using the `public` Folder\n\n\u003eNote: this feature is available with `react-scripts@0.5.0` and higher.\n\n### Changing the HTML\n\nThe `public` folder contains the HTML file so you can tweak it, for example, to [set the page title](#changing-the-page-title).\nThe `\u003cscript\u003e` tag with the compiled code will be added to it automatically during the build process.\n\n### Adding Assets Outside of the Module System\n\nYou can also add other assets to the `public` folder.\n\nNote that we normally encourage you to `import` assets in JavaScript files instead.\nFor example, see the sections on [adding a stylesheet](#adding-a-stylesheet) and [adding images and fonts](#adding-images-fonts-and-files).\nThis mechanism provides a number of benefits:\n\n* Scripts and stylesheets get minified and bundled together to avoid extra network requests.\n* Missing files cause compilation errors instead of 404 errors for your users.\n* Result filenames include content hashes so you don’t need to worry about browsers caching their old versions.\n\nHowever there is an **escape hatch** that you can use to add an asset outside of the module system.\n\nIf you put a file into the `public` folder, it will **not** be processed by Webpack. Instead it will be copied into the build folder untouched.   To reference assets in the `public` folder, you need to use a special variable called `PUBLIC_URL`.\n\nInside `index.html`, you can use it like this:\n\n```html\n\u003clink rel=\"shortcut icon\" href=\"%PUBLIC_URL%/favicon.ico\"\u003e\n```\n\nOnly files inside the `public` folder will be accessible by `%PUBLIC_URL%` prefix. If you need to use a file from `src` or `node_modules`, you’ll have to copy it there to explicitly specify your intention to make this file a part of the build.\n\nWhen you run `npm run build`, Create React App will substitute `%PUBLIC_URL%` with a correct absolute path so your project works even if you use client-side routing or host it at a non-root URL.\n\nIn JavaScript code, you can use `process.env.PUBLIC_URL` for similar purposes:\n\n```js\nrender() {\n  // Note: this is an escape hatch and should be used sparingly!\n  // Normally we recommend using `import` for getting asset URLs\n  // as described in “Adding Images and Fonts” above this section.\n  return \u003cimg src={process.env.PUBLIC_URL + '/img/logo.png'} /\u003e;\n}\n```\n\nKeep in mind the downsides of this approach:\n\n* None of the files in `public` folder get post-processed or minified.\n* Missing files will not be called at compilation time, and will cause 404 errors for your users.\n* Result filenames won’t include content hashes so you’ll need to add query arguments or rename them every time they change.\n\n### When to Use the `public` Folder\n\nNormally we recommend importing [stylesheets](#adding-a-stylesheet), [images, and fonts](#adding-images-fonts-and-files) from JavaScript.\nThe `public` folder is useful as a workaround for a number of less common cases:\n\n* You need a file with a specific name in the build output, such as [`manifest.webmanifest`](https://developer.mozilla.org/en-US/docs/Web/Manifest).\n* You have thousands of images and need to dynamically reference their paths.\n* You want to include a small script like [`pace.js`](http://github.hubspot.com/pace/docs/welcome/) outside of the bundled code.\n* Some library may be incompatible with Webpack and you have no other option but to include it as a `\u003cscript\u003e` tag.\n\nNote that if you add a `\u003cscript\u003e` that declares global variables, you also need to read the next section on using them.\n\n## Using Global Variables\n\nWhen you include a script in the HTML file that defines global variables and try to use one of these variables in the code, the linter will complain because it cannot see the definition of the variable.\n\nYou can avoid this by reading the global variable explicitly from the `window` object, for example:\n\n```js\nconst $ = window.$;\n```\n\nThis makes it obvious you are using a global variable intentionally rather than because of a typo.\n\nAlternatively, you can force the linter to ignore any line by adding `// eslint-disable-line` after it.\n\n## Adding Bootstrap\n\nYou don’t have to use [React Bootstrap](https://react-bootstrap.github.io) together with React but it is a popular library for integrating Bootstrap with React apps. If you need it, you can integrate it with Create React App by following these steps:\n\nInstall React Bootstrap and Bootstrap from npm. React Bootstrap does not include Bootstrap CSS so this needs to be installed as well:\n\n```sh\nnpm install --save react-bootstrap bootstrap@3\n```\n\nAlternatively you may use `yarn`:\n\n```sh\nyarn add react-bootstrap bootstrap@3\n```\n\nImport Bootstrap CSS and optionally Bootstrap theme CSS in the beginning of your ```src/index.js``` file:\n\n```js\nimport 'bootstrap/dist/css/bootstrap.css';\nimport 'bootstrap/dist/css/bootstrap-theme.css';\n// Put any other imports below so that CSS from your\n// components takes precedence over default styles.\n```\n\nImport required React Bootstrap components within ```src/App.js``` file or your custom component files:\n\n```js\nimport { Navbar, Jumbotron, Button } from 'react-bootstrap';\n```\n\nNow you are ready to use the imported React Bootstrap components within your component hierarchy defined in the render method. Here is an example [`App.js`](https://gist.githubusercontent.com/gaearon/85d8c067f6af1e56277c82d19fd4da7b/raw/6158dd991b67284e9fc8d70b9d973efe87659d72/App.js) redone using React Bootstrap.\n\n### Using a Custom Theme\n\nSometimes you might need to tweak the visual styles of Bootstrap (or equivalent package).\u003cbr\u003e\nWe suggest the following approach:\n\n* Create a new package that depends on the package you wish to customize, e.g. Bootstrap.\n* Add the necessary build steps to tweak the theme, and publish your package on npm.\n* Install your own theme npm package as a dependency of your app.\n\nHere is an example of adding a [customized Bootstrap](https://medium.com/@tacomanator/customizing-create-react-app-aa9ffb88165) that follows these steps.\n\n## Adding Flow\n\nFlow is a static type checker that helps you write code with fewer bugs. Check out this [introduction to using static types in JavaScript](https://medium.com/@preethikasireddy/why-use-static-types-in-javascript-part-1-8382da1e0adb) if you are new to this concept.\n\nRecent versions of [Flow](http://flowtype.org/) work with Create React App projects out of the box.\n\nTo add Flow to a Create React App project, follow these steps:\n\n1. Run `npm install --save flow-bin` (or `yarn add flow-bin`).\n2. Add `\"flow\": \"flow\"` to the `scripts` section of your `package.json`.\n3. Run `npm run flow init` (or `yarn flow init`) to create a [`.flowconfig` file](https://flowtype.org/docs/advanced-configuration.html) in the root directory.\n4. Add `// @flow` to any files you want to type check (for example, to `src/App.js`).\n\nNow you can run `npm run flow` (or `yarn flow`) to check the files for type errors.\nYou can optionally use an IDE like [Nuclide](https://nuclide.io/docs/languages/flow/) for a better integrated experience.\nIn the future we plan to integrate it into Create React App even more closely.\n\nTo learn more about Flow, check out [its documentation](https://flowtype.org/).\n\n## Adding a Router\n\nCreate React App doesn't prescribe a specific routing solution, but [React Router](https://reacttraining.com/react-router/) is the most popular one.\n\nTo add it, run:\n\n```sh\nnpm install --save react-router-dom\n```\n\nAlternatively you may use `yarn`:\n\n```sh\nyarn add react-router-dom\n```\n\nTo try it, delete all the code in `src/App.js` and replace it with any of the examples on its website. The [Basic Example](https://reacttraining.com/react-router/web/example/basic) is a good place to get started.\n\nNote that [you may need to configure your production server to support client-side routing](#serving-apps-with-client-side-routing) before deploying your app.\n\n## Adding Custom Environment Variables\n\n\u003eNote: this feature is available with `react-scripts@0.2.3` and higher.\n\nYour project can consume variables declared in your environment as if they were declared locally in your JS files. By\ndefault you will have `NODE_ENV` defined for you, and any other environment variables starting with\n`REACT_APP_`.\n\n**The environment variables are embedded during the build time**. Since Create React App produces a static HTML/CSS/JS bundle, it can’t possibly read them at runtime. To read them at runtime, you would need to load HTML into memory on the server and replace placeholders in runtime, just like [described here](#injecting-data-from-the-server-into-the-page). Alternatively you can rebuild the app on the server anytime you change them.\n\n\u003eNote: You must create custom environment variables beginning with `REACT_APP_`. Any other variables except `NODE_ENV` will be ignored to avoid accidentally [exposing a private key on the machine that could have the same name](https://github.com/facebookincubator/create-react-app/issues/865#issuecomment-252199527). Changing any environment variables will require you to restart the development server if it is running.\n\nThese environment variables will be defined for you on `process.env`. For example, having an environment\nvariable named `REACT_APP_SECRET_CODE` will be exposed in your JS as `process.env.REACT_APP_SECRET_CODE`.\n\nThere is also a special built-in environment variable called `NODE_ENV`. You can read it from `process.env.NODE_ENV`. When you run `npm start`, it is always equal to `'development'`, when you run `npm test` it is always equal to `'test'`, and when you run `npm run build` to make a production bundle, it is always equal to `'production'`. **You cannot override `NODE_ENV` manually.** This prevents developers from accidentally deploying a slow development build to production.\n\nThese environment variables can be useful for displaying information conditionally based on where the project is\ndeployed or consuming sensitive data that lives outside of version control.\n\nFirst, you need to have environment variables defined. For example, let’s say you wanted to consume a secret defined\nin the environment inside a `\u003cform\u003e`:\n\n```jsx\nrender() {\n  return (\n    \u003cdiv\u003e\n      \u003csmall\u003eYou are running this application in \u003cb\u003e{process.env.NODE_ENV}\u003c/b\u003e mode.\u003c/small\u003e\n      \u003cform\u003e\n        \u003cinput type=\"hidden\" defaultValue={process.env.REACT_APP_SECRET_CODE} /\u003e\n      \u003c/form\u003e\n    \u003c/div\u003e\n  );\n}\n```\n\nDuring the build, `process.env.REACT_APP_SECRET_CODE` will be replaced with the current value of the `REACT_APP_SECRET_CODE` environment variable. Remember that the `NODE_ENV` variable will be set for you automatically.\n\nWhen you load the app in the browser and inspect the `\u003cinput\u003e`, you will see its value set to `abcdef`, and the bold text will show the environment provided when using `npm start`:\n\n```html\n\u003cdiv\u003e\n  \u003csmall\u003eYou are running this application in \u003cb\u003edevelopment\u003c/b\u003e mode.\u003c/small\u003e\n  \u003cform\u003e\n    \u003cinput type=\"hidden\" value=\"abcdef\" /\u003e\n  \u003c/form\u003e\n\u003c/div\u003e\n```\n\nThe above form is looking for a variable called `REACT_APP_SECRET_CODE` from the environment. In order to consume this\nvalue, we need to have it defined in the environment. This can be done using two ways: either in your shell or in\na `.env` file. Both of these ways are described in the next few sections.\n\nHaving access to the `NODE_ENV` is also useful for performing actions conditionally:\n\n```js\nif (process.env.NODE_ENV !== 'production') {\n  analytics.disable();\n}\n```\n\nWhen you compile the app with `npm run build`, the minification step will strip out this condition, and the resulting bundle will be smaller.\n\n### Referencing Environment Variables in the HTML\n\n\u003eNote: this feature is available with `react-scripts@0.9.0` and higher.\n\nYou can also access the environment variables starting with `REACT_APP_` in the `public/index.html`. For example:\n\n```html\n\u003ctitle\u003e%REACT_APP_WEBSITE_NAME%\u003c/title\u003e\n```\n\nNote that the caveats from the above section apply:\n\n* Apart from a few built-in variables (`NODE_ENV` and `PUBLIC_URL`), variable names must start with `REACT_APP_` to work.\n* The environment variables are injected at build time. If you need to inject them at runtime, [follow this approach instead](#generating-dynamic-meta-tags-on-the-server).\n\n### Adding Temporary Environment Variables In Your Shell\n\nDefining environment variables can vary between OSes. It’s also important to know that this manner is temporary for the\nlife of the shell session.\n\n#### Windows (cmd.exe)\n\n```cmd\nset \"REACT_APP_SECRET_CODE=abcdef\" \u0026\u0026 npm start\n```\n\n(Note: Quotes around the variable assignment are required to avoid a trailing whitespace.)\n\n#### Windows (Powershell)\n\n```Powershell\n($env:REACT_APP_SECRET_CODE = \"abcdef\") -and (npm start)\n```\n\n#### Linux, macOS (Bash)\n\n```bash\nREACT_APP_SECRET_CODE=abcdef npm start\n```\n\n### Adding Development Environment Variables In `.env`\n\n\u003eNote: this feature is available with `react-scripts@0.5.0` and higher.\n\nTo define permanent environment variables, create a file called `.env` in the root of your project:\n\n```\nREACT_APP_SECRET_CODE=abcdef\n```\n\u003eNote: You must create custom environment variables beginning with `REACT_APP_`. Any other variables except `NODE_ENV` will be ignored to avoid [accidentally exposing a private key on the machine that could have the same name](https://github.com/facebookincubator/create-react-app/issues/865#issuecomment-252199527). Changing any environment variables will require you to restart the development server if it is running.\n\n`.env` files **should be** checked into source control (with the exclusion of `.env*.local`).\n\n#### What other `.env` files can be used?\n\n\u003eNote: this feature is **available with `react-scripts@1.0.0` and higher**.\n\n* `.env`: Default.\n* `.env.local`: Local overrides. **This file is loaded for all environments except test.**\n* `.env.development`, `.env.test`, `.env.production`: Environment-specific settings.\n* `.env.development.local`, `.env.test.local`, `.env.production.local`: Local overrides of environment-specific settings.\n\nFiles on the left have more priority than files on the right:\n\n* `npm start`: `.env.development.local`, `.env.development`, `.env.local`, `.env`\n* `npm run build`: `.env.production.local`, `.env.production`, `.env.local`, `.env`\n* `npm test`: `.env.test.local`, `.env.test`, `.env` (note `.env.local` is missing)\n\nThese variables will act as the defaults if the machine does not explicitly set them.\u003cbr\u003e\nPlease refer to the [dotenv documentation](https://github.com/motdotla/dotenv) for more details.\n\n\u003eNote: If you are defining environment variables for development, your CI and/or hosting platform will most likely need\nthese defined as well. Consult their documentation how to do this. For example, see the documentation for [Travis CI](https://docs.travis-ci.com/user/environment-variables/) or [Heroku](https://devcenter.heroku.com/articles/config-vars).\n\n#### Expanding Environment Variables In `.env`\n\n\u003eNote: this feature is available with `react-scripts@1.1.0` and higher.\n\nExpand variables already on your machine for use in your `.env` file (using [dotenv-expand](https://github.com/motdotla/dotenv-expand)).\n\nFor example, to get the environment variable `npm_package_version`:\n\n```\nREACT_APP_VERSION=$npm_package_version\n# also works:\n# REACT_APP_VERSION=${npm_package_version}\n```\n\nOr expand variables local to the current `.env` file:\n\n```\nDOMAIN=www.example.com\nREACT_APP_FOO=$DOMAIN/foo\nREACT_APP_BAR=$DOMAIN/bar\n```\n\n## Can I Use Decorators?\n\nMany popular libraries use [decorators](https://medium.com/google-developers/exploring-es7-decorators-76ecb65fb841) in their documentation.\u003cbr\u003e\nCreate React App doesn’t support decorator syntax at the moment because:\n\n* It is an experimental proposal and is subject to change.\n* The current specification version is not officially supported by Babel.\n* If the specification changes, we won’t be able to write a codemod because we don’t use them internally at Facebook.\n\nHowever in many cases you can rewrite decorator-based code without decorators just as fine.\u003cbr\u003e\nPlease refer to these two threads for reference:\n\n* [#214](https://github.com/facebookincubator/create-react-app/issues/214)\n* [#411](https://github.com/facebookincubator/create-react-app/issues/411)\n\nCreate React App will add decorator support when the specification advances to a stable stage.\n\n## Fetching Data with AJAX Requests\n\nReact doesn't prescribe a specific approach to data fetching, but people commonly use either a library like [axios](https://github.com/axios/axios) or the [`fetch()` API](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API) provided by the browser. Conveniently, Create React App includes a polyfill for `fetch()` so you can use it without worrying about the browser support.\n\nThe global `fetch` function allows to easily makes AJAX requests. It takes in a URL as an input and returns a `Promise` that resolves to a `Response` object. You can find more information about `fetch` [here](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch).\n\nThis project also includes a [Promise polyfill](https://github.com/then/promise) which provides a full implementation of Promises/A+. A Promise represents the eventual result of an asynchronous operation, you can find more information about Promises [here](https://www.promisejs.org/) and [here](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise). Both axios and `fetch()` use Promises under the hood. You can also use the [`async / await`](https://davidwalsh.name/async-await) syntax to reduce the callback nesting.\n\nYou can learn more about making AJAX requests from React components in [the FAQ entry on the React website](https://reactjs.org/docs/faq-ajax.html).\n\n## Integrating with an API Backend\n\nThese tutorials will help you to integrate your app with an API backend running on another port,\nusing `fetch()` to access it.\n\n### Node\nCheck out [this tutorial](https://www.fullstackreact.com/articles/using-create-react-app-with-a-server/).\nYou can find the companion GitHub repository [here](https://github.com/fullstackreact/food-lookup-demo).\n\n### Ruby on Rails\n\nCheck out [this tutorial](https://www.fullstackreact.com/articles/how-to-get-create-react-app-to-work-with-your-rails-api/).\nYou can find the companion GitHub repository [here](https://github.com/fullstackreact/food-lookup-demo-rails).\n\n## Proxying API Requests in Development\n\n\u003eNote: this feature is available with `react-scripts@0.2.3` and higher.\n\nPeople often serve the front-end React app from the same host and port as their backend implementation.\u003cbr\u003e\nFor example, a production setup might look like this after the app is deployed:\n\n```\n/             - static server returns index.html with React app\n/todos        - static server returns index.html with React app\n/api/todos    - server handles any /api/* requests using the backend implementation\n```\n\nSuch setup is **not** required. However, if you **do** have a setup like this, it is convenient to write requests like `fetch('/api/todos')` without worrying about redirecting them to another host or port during development.\n\nTo tell the development server to proxy any unknown requests to your API server in development, add a `proxy` field to your `package.json`, for example:\n\n```js\n  \"proxy\": \"http://localhost:4000\",\n```\n\nThis way, when you `fetch('/api/todos')` in development, the development server will recognize that it’s not a static asset, and will proxy your request to `http://localhost:4000/api/todos` as a fallback. The development server will **only** attempt to send requests without `text/html` in its `Accept` header to the proxy.\n\nConveniently, this avoids [CORS issues](http://stackoverflow.com/questions/21854516/understanding-ajax-cors-and-security-considerations) and error messages like this in development:\n\n```\nFetch API cannot load http://localhost:4000/api/todos. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:3000' is therefore not allowed access. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.\n```\n\nKeep in mind that `proxy` only has effect in development (with `npm start`), and it is up to you to ensure that URLs like `/api/todos` point to the right thing in production. You don’t have to use the `/api` prefix. Any unrecognized request without a `text/html` accept header will be redirected to the specified `proxy`.\n\nThe `proxy` option supports HTTP, HTTPS and WebSocket connections.\u003cbr\u003e\nIf the `proxy` option is **not** flexible enough for you, alternatively you can:\n\n* [Configure the proxy yourself](#configuring-the-proxy-manually)\n* Enable CORS on your server ([here’s how to do it for Express](http://enable-cors.org/server_expressjs.html)).\n* Use [environment variables](#adding-custom-environment-variables) to inject the right server host and port into your app.\n\n### \"Invalid Host Header\" Errors After Configuring Proxy\n\nWhen you enable the `proxy` option, you opt into a more strict set of host checks. This is necessary because leaving the backend open to remote hosts makes your computer vulnerable to DNS rebinding attacks. The issue is explained in [this article](https://medium.com/webpack/webpack-dev-server-middleware-security-issues-1489d950874a) and [this issue](https://github.com/webpack/webpack-dev-server/issues/887).\n\nThis shouldn’t affect you when developing on `localhost`, but if you develop remotely like [described here](https://github.com/facebookincubator/create-react-app/issues/2271), you will see this error in the browser after enabling the `proxy` option:\n\n\u003eInvalid Host header\n\nTo work around it, you can specify your public development host in a file called `.env.development` in the root of your project:\n\n```\nHOST=mypublicdevhost.com\n```\n\nIf you restart the development server now and load the app from the specified host, it should work.\n\nIf you are still having issues or if you’re using a more exotic environment like a cloud editor, you can bypass the host check completely by adding a line to `.env.development.local`. **Note that this is dangerous and exposes your machine to remote code execution from malicious websites:**\n\n```\n# NOTE: THIS IS DANGEROUS!\n# It exposes your machine to attacks from the websites you visit.\nDANGEROUSLY_DISABLE_HOST_CHECK=true\n```\n\nWe don’t recommend this approach.\n\n### Configuring the Proxy Manually\n\n\u003eNote: this feature is available with `react-scripts@1.0.0` and higher.\n\nIf the `proxy` option is **not** flexible enough for you, you can specify an object in the following form (in `package.json`).\u003cbr\u003e\nYou may also specify any configuration value [`http-proxy-middleware`](https://github.com/chimurai/http-proxy-middleware#options) or [`http-proxy`](https://github.com/nodejitsu/node-http-proxy#options) supports.\n```js\n{\n  // ...\n  \"proxy\": {\n    \"/api\": {\n      \"target\": \"\u003curl\u003e\",\n      \"ws\": true\n      // ...\n    }\n  }\n  // ...\n}\n```\n\nAll requests matching this path will be proxies, no exceptions. This includes requests for `text/html`, which the standard `proxy` option does not proxy.\n\nIf you need to specify multiple proxies, you may do so by specifying additional entries.\nMatches are regular expressions, so that you can use a regexp to match multiple paths.\n```js\n{\n  // ...\n  \"proxy\": {\n    // Matches any request starting with /api\n    \"/api\": {\n      \"target\": \"\u003curl_1\u003e\",\n      \"ws\": true\n      // ...\n    },\n    // Matches any request starting with /foo\n    \"/foo\": {\n      \"target\": \"\u003curl_2\u003e\",\n      \"ssl\": true,\n      \"pathRewrite\": {\n        \"^/foo\": \"/foo/beta\"\n      }\n      // ...\n    },\n    // Matches /bar/abc.html but not /bar/sub/def.html\n    \"/bar/[^/]*[.]html\": {\n      \"target\": \"\u003curl_3\u003e\",\n      // ...\n    },\n    // Matches /baz/abc.html and /baz/sub/def.html\n    \"/baz/.*/.*[.]html\": {\n      \"target\": \"\u003curl_4\u003e\"\n      // ...\n    }\n  }\n  // ...\n}\n```\n\n### Configuring a WebSocket Proxy\n\nWhen setting up a WebSocket proxy, there are a some extra considerations to be aware of.\n\nIf you’re using a WebSocket engine like [Socket.io](https://socket.io/), you must have a Socket.io server running that you can use as the proxy target. Socket.io will not work with a standard WebSocket server. Specifically, don't expect Socket.io to work with [the websocket.org echo test](http://websocket.org/echo.html).\n\nThere’s some good documentation available for [setting up a Socket.io server](https://socket.io/docs/).\n\nStandard WebSockets **will** work with a standard WebSocket server as well as the websocket.org echo test. You can use libraries like [ws](https://github.com/websockets/ws) for the server, with [native WebSockets in the browser](https://developer.mozilla.org/en-US/docs/Web/API/WebSocket).\n\nEither way, you can proxy WebSocket requests manually in `package.json`:\n\n```js\n{\n  // ...\n  \"proxy\": {\n    \"/socket\": {\n      // Your compatible WebSocket server\n      \"target\": \"ws://\u003csocket_url\u003e\",\n      // Tell http-proxy-middleware that this is a WebSocket proxy.\n      // Also allows you to proxy WebSocket requests without an additional HTTP request\n      // https://github.com/chimurai/http-proxy-middleware#external-websocket-upgrade\n      \"ws\": true\n      // ...\n    }\n  }\n  // ...\n}\n```\n\n## Using HTTPS in Development\n\n\u003eNote: this feature is available with `react-scripts@0.4.0` and higher.\n\nYou may require the dev server to serve pages over HTTPS. One particular case where this could be useful is when using [the \"proxy\" feature](#proxying-api-requests-in-development) to proxy requests to an API server when that API server is itself serving HTTPS.\n\nTo do this, set the `HTTPS` environment variable to `true`, then start the dev server as usual with `npm start`:\n\n#### Windows (cmd.exe)\n\n```cmd\nset HTTPS=true\u0026\u0026npm start\n```\n\n#### Windows (Powershell)\n\n```Powershell\n($env:HTTPS = $true) -and (npm start)\n```\n\n(Note: the lack of whitespace is intentional.)\n\n#### Linux, macOS (Bash)\n\n```bash\nHTTPS=true npm start\n```\n\nNote that the server will use a self-signed certificate, so your web browser will almost definitely display a warning upon accessing the page.\n\n## Generating Dynamic `\u003cmeta\u003e` Tags on the Server\n\nSince Create React App doesn’t support server rendering, you might be wondering how to make `\u003cmeta\u003e` tags dynamic and reflect the current URL. To solve this, we recommend to add placeholders into the HTML, like this:\n\n```html\n\u003c!doctype html\u003e\n\u003chtml lang=\"en\"\u003e\n  \u003chead\u003e\n    \u003cmeta property=\"og:title\" content=\"__OG_TITLE__\"\u003e\n    \u003cmeta property=\"og:description\" content=\"__OG_DESCRIPTION__\"\u003e\n```\n\nThen, on the server, regardless of the backend you use, you can read `index.html` into memory and replace `__OG_TITLE__`, `__OG_DESCRIPTION__`, and any other placeholders with values depending on the current URL. Just make sure to sanitize and escape the interpolated values so that they are safe to embed into HTML!\n\nIf you use a Node server, you can even share the route matching logic between the client and the server. However duplicating it also works fine in simple cases.\n\n## Pre-Rendering into Static HTML Files\n\nIf you’re hosting your `build` with a static hosting provider you can use [react-snapshot](https://www.npmjs.com/package/react-snapshot) or [react-snap](https://github.com/stereobooster/react-snap) to generate HTML pages for each route, or relative link, in your application. These pages will then seamlessly become active, or “hydrated”, when the JavaScript bundle has loaded.\n\nThere are also opportunities to use this outside of static hosting, to take the pressure off the server when generating and caching routes.\n\nThe primary benefit of pre-rendering is that you get the core content of each page _with_ the HTML payload—regardless of whether or not your JavaScript bundle successfully downloads. It also increases the likelihood that each route of your application will be picked up by search engines.\n\nYou can read more about [zero-configuration pre-rendering (also called snapshotting) here](https://medium.com/superhighfives/an-almost-static-stack-6df0a2791319).\n\n## Injecting Data from the Server into the Page\n\nSimilarly to the previous section, you can leave some placeholders in the HTML that inject global variables, for example:\n\n```js\n\u003c!doctype html\u003e\n\u003chtml lang=\"en\"\u003e\n  \u003chead\u003e\n    \u003cscript\u003e\n      window.SERVER_DATA = __SERVER_DATA__;\n    \u003c/script\u003e\n```\n\nThen, 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.**\n\n## Running Tests\n\n\u003eNote: this feature is available with `react-scripts@0.3.0` and higher.\u003cbr\u003e\n\u003e[Read the migration guide to learn how to enable it in older projects!](https://github.com/facebookincubator/create-react-app/blob/master/CHANGELOG.md#migrating-from-023-to-030)\n\nCreate React App uses [Jest](https://facebook.github.io/jest/) as its test runner. To prepare for this integration, we did a [major revamp](https://facebook.github.io/jest/blog/2016/09/01/jest-15.html) of Jest so if you heard bad things about it years ago, give it another try.\n\nJest is a Node-based runner. This means that the tests always run in a Node environment and not in a real browser. This lets us enable fast iteration speed and prevent flakiness.\n\nWhile Jest provides browser globals such as `window` thanks to [jsdom](https://github.com/tmpvar/jsdom), they are only approximations of the real browser behavior. Jest is intended to be used for unit tests of your logic and your components rather than the DOM quirks.\n\nWe recommend that you use a separate tool for browser end-to-end tests if you need them. They are beyond the scope of Create React App.\n\n### Filename Conventions\n\nJest will look for test files with any of the following popular naming conventions:\n\n* Files with `.js` suffix in `__tests__` folders.\n* Files with `.test.js` suffix.\n* Files with `.spec.js` suffix.\n\nThe `.test.js` / `.spec.js` files (or the `__tests__` folders) can be located at any depth under the `src` top level folder.\n\nWe recommend to put the test files (or `__tests__` folders) next to the code they are testing so that relative imports appear shorter. For example, if `App.test.js` and `App.js` are in the same folder, the test just needs to `import App from './App'` instead of a long relative path. Colocation also helps find tests more quickly in larger projects.\n\n### Command Line Interface\n\nWhen you run `npm test`, Jest will launch in the watch mode. Every time you save a file, it will re-run the tests, just like `npm start` recompiles the code.\n\nThe watcher includes an interactive command-line interface with the ability to run all tests, or focus on a search pattern. It is designed this way so that you can keep it open and enjoy fast re-runs. You can learn the commands from the “Watch Usage” note that the watcher prints after every run:\n\n![Jest watch mode](http://facebook.github.io/jest/img/blog/15-watch.gif)\n\n### Version Control Integration\n\nBy default, when you run `npm test`, Jest will only run the tests related to files changed since the last commit. This is an optimization designed to make your tests run fast regardless of how many tests you have. However it assumes that you don’t often commit the code that doesn’t pass the tests.\n\nJest will always explicitly mention that it only ran tests related to the files changed since the last commit. You can also press `a` in the watch mode to force Jest to run all tests.\n\nJest will always run all tests on a [continuous integration](#continuous-integration) server or if the project is not inside a Git or Mercurial repository.\n\n### Writing Tests\n\nTo create tests, add `it()` (or `test()`) blocks with the name of the test and its code. You may optionally wrap them in `describe()` blocks for logical grouping but this is neither required nor recommended.\n\nJest provides a built-in `expect()` global function for making assertions. A basic test could look like this:\n\n```js\nimport sum from './sum';\n\nit('sums numbers', () =\u003e {\n  expect(sum(1, 2)).toEqual(3);\n  expect(sum(2, 2)).toEqual(4);\n});\n```\n\nAll `expect()` matchers supported by Jest are [extensively documented here](https://facebook.github.io/jest/docs/en/expect.html#content).\u003cbr\u003e\nYou can also use [`jest.fn()` and `expect(fn).toBeCalled()`](https://facebook.github.io/jest/docs/en/expect.html#tohavebeencalled) to create “spies” or mock functions.\n\n### Testing Components\n\nThere is a broad spectrum of component testing techniques. They range from a “smoke test” verifying that a component renders without throwing, to shallow rendering and testing some of the output, to full rendering and testing component lifecycle and state changes.\n\nDifferent projects choose different testing tradeoffs based on how often components change, and how much logic they contain. If you haven’t decided on a testing strategy yet, we recommend that you start with creating simple smoke tests for your components:\n\n```js\nimport React from 'react';\nimport ReactDOM from 'react-dom';\nimport App from './App';\n\nit('renders without crashing', () =\u003e {\n  const div = document.createElement('div');\n  ReactDOM.render(\u003cApp /\u003e, div);\n});\n```\n\nThis test mounts a component and makes sure that it didn’t throw during rendering. Tests like this provide a lot of value with very little effort so they are great as a starting point, and this is the test you will find in `src/App.test.js`.\n\nWhen you encounter bugs caused by changing components, you will gain a deeper insight into which parts of them are worth testing in your application. This might be a good time to introduce more specific tests asserting specific expected output or behavior.\n\nIf you’d like to test components in isolation from the child components they render, we recommend using [`shallow()` rendering API](http://airbnb.io/enzyme/docs/api/shallow.html) from [Enzyme](http://airbnb.io/enzyme/). To install it, run:\n\n```sh\nnpm install --save enzyme enzyme-adapter-react-16 react-test-renderer\n```\n\nAlternatively you may use `yarn`:\n\n```sh\nyarn add enzyme enzyme-adapter-react-16 react-test-renderer\n```\n\nAs of Enzyme 3, you will need to install Enzyme along with an Adapter corresponding to the version of React you are using. (The examples above use the adapter for React 16.)\n\nThe adapter will also need to be configured in your [global setup file](#initializing-test-environment):\n\n#### `src/setupTests.js`\n```js\nimport { configure } from 'enzyme';\nimport Adapter from 'enzyme-adapter-react-16';\n\nconfigure({ adapter: new Adapter() });\n```\n\n\u003eNote: Keep in mind that if you decide to \"eject\" before creating `src/setupTests.js`, the resulting `package.json` file won't contain any reference to it. [Read here](#initializing-test-environment) to learn how to add this after ejecting.\n\nNow you can write a smoke test with it:\n\n```js\nimport React from 'react';\nimport { shallow } from 'enzyme';\nimport App from './App';\n\nit('renders without crashing', () =\u003e {\n  shallow(\u003cApp /\u003e);\n});\n```\n\nUnlike the previous smoke test using `ReactDOM.render()`, this test only renders `\u003cApp\u003e` and doesn’t go deeper. For example, even if `\u003cApp\u003e` itself renders a `\u003cButton\u003e` that throws, this test will pass. Shallow rendering is great for isolated unit tests, but you may still want to create some full rendering tests to ensure the components integrate correctly. Enzyme supports [full rendering with `mount()`](http://airbnb.io/enzyme/docs/api/mount.html), and you can also use it for testing state changes and component lifecycle.\n\nYou can read the [Enzyme documentation](http://airbnb.io/enzyme/) for more testing techniques. Enzyme documentation uses Chai and Sinon for assertions but you don’t have to use them because Jest provides built-in `expect()` and `jest.fn()` for spies.\n\nHere is an example from Enzyme documentation that asserts specific output, rewritten to use Jest matchers:\n\n```js\nimport React from 'react';\nimport { shallow } from 'enzyme';\nimport App from './App';\n\nit('renders welcome message', () =\u003e {\n  const wrapper = shallow(\u003cApp /\u003e);\n  const welcome = \u003ch2\u003eWelcome to React\u003c/h2\u003e;\n  // expect(wrapper.contains(welcome)).to.equal(true);\n  expect(wrapper.contains(welcome)).toEqual(true);\n});\n```\n\nAll Jest matchers are [extensively documented here](http://facebook.github.io/jest/docs/en/expect.html).\u003cbr\u003e\nNevertheless you can use a third-party assertion library like [Chai](http://chaijs.com/) if you want to, as described below.\n\nAdditionally, you might find [jest-enzyme](https://github.com/blainekasten/enzyme-matchers) helpful to simplify your tests with readable matchers. The above `contains` code can be written more simply with jest-enzyme.\n\n```js\nexpect(wrapper).toContainReact(welcome)\n```\n\nTo enable this, install `jest-enzyme`:\n\n```sh\nnpm install --save jest-enzyme\n```\n\nAlternatively you may use `yarn`:\n\n```sh\nyarn add jest-enzyme\n```\n\nImport it in [`src/setupTests.js`](#initializing-test-environment) to make its matchers available in every test:\n\n```js\nimport 'jest-enzyme';\n```\n\n### Using Third Party Assertion Libraries\n\nWe recommend that you use `expect()` for assertions and `jest.fn()` for spies. If you are having issues with them please [file those against Jest](https://github.com/facebook/jest/issues/new), and we’ll fix them. We intend to keep making them better for React, supporting, for example, [pretty-printing React elements as JSX](https://github.com/facebook/jest/pull/1566).\n\nHowever, if you are used to other libraries, such as [Chai](http://chaijs.com/) and [Sinon](http://sinonjs.org/), or if you have existing code using them that you’d like to port over, you can import them normally like this:\n\n```js\nimport sinon from 'sinon';\nimport { expect } from 'chai';\n```\n\nand then use them in your tests like you normally do.\n\n### Initializing Test Environment\n\n\u003eNote: this feature is available with `react-scripts@0.4.0` and higher.\n\nIf your app uses a browser API that you need to mock in your tests or if you just need a global setup before running your tests, add a `src/setupTests.js` to your project. It will be automatically executed before running your tests.\n\nFor example:\n\n#### `src/setupTests.js`\n```js\nconst localStorageMock = {\n  getItem: jest.fn(),\n  setItem: jest.fn(),\n  clear: jest.fn()\n};\nglobal.localStorage = localStorageMock\n```\n\n\u003eNote: Keep in mind that if you decide to \"eject\" before creating `src/setupTests.js`, the resulting `package.json` file won't contain any reference to it, so you should manually create the property `setupTestFrameworkScriptFile` in the configuration for Jest, something like the following:\n\n\u003e```js\n\u003e\"jest\": {\n\u003e   // ...\n\u003e   \"setupTestFrameworkScriptFile\": \"\u003crootDir\u003e/src/setupTests.js\"\n\u003e  }\n\u003e  ```\n\n### Focusing and Excluding Tests\n\nYou can replace `it()` with `xit()` to temporarily exclude a test from being executed.\u003cbr\u003e\nSimilarly, `fit()` lets you focus on a specific test without running any other tests.\n\n### Coverage Reporting\n\nJest has an integrated coverage reporter that works well with ES6 and requires no configuration.\u003cbr\u003e\nRun `npm test -- --coverage` (note extra `--` in the middle) to include a coverage report like this:\n\n![coverage report](http://i.imgur.com/5bFhnTS.png)\n\nNote that tests run much slower with coverage so it is recommended to run it separately from your normal workflow.\n\n#### Configuration\n\nThe default Jest coverage configuration can be overriden by adding any of the following supported keys to a Jest config in your package.json.\n\nSupported overrides:\n - [`collectCoverageFrom`](https://facebook.github.io/jest/docs/en/configuration.html#collectcoveragefrom-array)\n - [`coverageReporters`](https://facebook.github.io/jest/docs/en/configuration.html#coveragereporters-array-string)\n - [`coverageThreshold`](https://facebook.github.io/jest/docs/en/configuration.html#coveragethreshold-object)\n - [`snapshotSerializers`](https://facebook.github.io/jest/docs/en/configuration.html#snapshotserializers-array-string)\n\nExample package.json:\n\n```json\n{\n  \"name\": \"your-package\",\n  \"jest\": {\n    \"collectCoverageFrom\" : [\n      \"src/**/*.{js,jsx}\",\n      \"!\u003crootDir\u003e/node_modules/\",\n      \"!\u003crootDir\u003e/path/to/dir/\"\n    ],\n    \"coverageThreshold\": {\n      \"global\": {\n        \"branches\": 90,\n        \"functions\": 90,\n        \"lines\": 90,\n        \"statements\": 90\n      }\n    },\n    \"coverageReporters\": [\"text\"],\n    \"snapshotSerializers\": [\"my-serializer-module\"]\n  }\n}\n```\n\n### Continuous Integration\n\nBy default `npm test` runs the watcher with interactive CLI. However, you can force it to run tests once and finish the process by setting an environment variable called `CI`.\n\nWhen creating a build of your application with `npm run build` linter warnings are not checked by default. Like `npm test`, you can force the build to perform a linter warning check by setting the environment variable `CI`. If any warnings are encountered then the build fails.\n\nPopular CI servers already set the environment variable `CI` by default but you can do this yourself too:\n\n### On CI servers\n#### Travis CI\n\n1. Following the [Travis Getting started](https://docs.travis-ci.com/user/getting-started/) guide for syncing your GitHub repository with Travis.  You may need to initialize some settings manually in your [profile](https://travis-ci.org/profile) page.\n1. Add a `.travis.yml` file to your git repository.\n```\nlanguage: node_js\nnode_js:\n  - 6\ncache:\n  directories:\n    - node_modules\nscript:\n  - npm run build\n  - npm test\n```\n1. Trigger your first build with a git push.\n1. [Customize your Travis CI Build](https://docs.travis-ci.com/user/customizing-the-build/) if needed.\n\n#### CircleCI\n\nFollow [this article](https://medium.com/@knowbody/circleci-and-zeits-now-sh-c9b7eebcd3c1) to set up CircleCI with a Create React App project.\n\n### On your own environment\n##### Windows (cmd.exe)\n\n```cmd\nset CI=true\u0026\u0026npm test\n```\n\n```cmd\nset CI=true\u0026\u0026npm run build\n```\n\n(Note: the lack of whitespace is intentional.)\n\n##### Windows (Powershell)\n\n```Powershell\n($env:CI = $true) -and (npm test)\n```\n\n```Powershell\n($env:CI = $true) -and (npm run build)\n```\n\n##### Linux, macOS (Bash)\n\n```bash\nCI=true npm test\n```\n\n```bash\nCI=true npm run build\n```\n\nThe test command will force Jest to run tests once instead of launching the watcher.\n\n\u003e  If you find yourself doing this often in development, please [file an issue](https://github.com/facebookincubator/create-react-app/issues/new) to tell us about your use case because we want to make watcher the best experience and are open to changing how it works to accommodate more workflows.\n\nThe build command will check for linter warnings and fail if any are found.\n\n### Disabling jsdom\n\nBy default, the `package.json` of the generated project looks like this:\n\n```js\n  \"scripts\": {\n    \"start\": \"react-scripts start\",\n    \"build\": \"react-scripts build\",\n    \"test\": \"react-scripts test --env=jsdom\"\n```\n\nIf you know that none of your tests depend on [jsdom](https://github.com/tmpvar/jsdom), you can safely remove `--env=jsdom`, and your tests will run faster:\n\n```diff\n  \"scripts\": {\n    \"start\": \"react-scripts start\",\n    \"build\": \"react-scripts build\",\n-   \"test\": \"react-scripts test --env=jsdom\"\n+   \"test\": \"react-scripts test\"\n```\n\nTo help you make up your mind, here is a list of APIs that **need jsdom**:\n\n* Any browser globals like `window` and `document`\n* [`ReactDOM.render()`](https://facebook.github.io/react/docs/top-level-api.html#reactdom.render)\n* [`TestUtils.renderIntoDocument()`](https://facebook.github.io/react/docs/test-utils.html#renderintodocument) ([a shortcut](https://github.com/facebook/react/blob/34761cf9a252964abfaab6faf74d473ad95d1f21/src/test/ReactTestUtils.js#L83-L91) for the above)\n* [`mount()`](http://airbnb.io/enzyme/docs/api/mount.html) in [Enzyme](http://airbnb.io/enzyme/index.html)\n\nIn contrast, **jsdom is not needed** for the following APIs:\n\n* [`TestUtils.createRenderer()`](https://facebook.github.io/react/docs/test-utils.html#shallow-rendering) (shallow rendering)\n* [`shallow()`](http://airbnb.io/enzyme/docs/api/shallow.html) in [Enzyme](http://airbnb.io/enzyme/index.html)\n\nFinally, jsdom is also not needed for [snapshot testing](http://facebook.github.io/jest/blog/2016/07/27/jest-14.html).\n\n### Snapshot Testing\n\nSnapshot testing is a feature of Jest that automatically generates text snapshots of your components and saves them on the disk so if the UI output changes, you get notified without manually writing any assertions on the component output. [Read more about snapshot testing.](http://facebook.github.io/jest/blog/2016/07/27/jest-14.html)\n\n### Editor Integration\n\nIf you use [Visual Studio Code](https://code.visualstudio.com), there is a [Jest extension](https://github.com/orta/vscode-jest) which works with Create React App out of the box. This provides a lot of IDE-like features while using a text editor: showing the status of a test run with potential fail messages inline, starting and stopping the watcher automatically, and offering one-click snapshot updates.\n\n![VS Code Jest Preview](https://cloud.githubusercontent.com/assets/49038/20795349/a032308a-b7c8-11e6-9b34-7eeac781003f.png)\n\n## Debugging Tests\n\nThere are various ways to setup a debugger for your Jest tests. We cover debugging in Chrome and [Visual Studio Code](https://code.visualstudio.com/).\n\n\u003eNote: debugging tests requires Node 8 or higher.\n\n### Debugging Tests in Chrome\n\nAdd the following to the `scripts` section in your project's `package.json`\n```json\n\"scripts\": {\n    \"test:debug\": \"react-scripts --inspect-brk test --runInBand --env=jsdom\"\n  }\n```\nPlace `debugger;` statements in any test and run:\n```bash\n$ npm run test:debug\n```\n\nThis will start running your Jest tests, but pause before executing to allow a debugger to attach to the process.\n\nOpen the following in Chrome\n```\nabout:inspect\n```\n\nAfter opening that link, the Chrome Developer Tools will be displayed. Select `inspect` on your process and a breakpoint will be set at the first line of the react script (this is done simply to give you time to open the developer tools and to prevent Jest from executing before you have time to do so). Click the button that looks like a \"play\" button in the upper right hand side of the screen to continue execution. When Jest executes the test that contains the debugger statement, execution will pause and you can examine the current scope and call stack.\n\n\u003eNote: the --runInBand cli option makes sure Jest runs test in the same process rather than spawning processes for individual tests. Normally Jest parallelizes test runs across processes but it is hard to debug many processes at the same time.\n\n### Debugging Tests in Visual Studio Code\n\nDebugging Jest tests is supported out of the box for [Visual Studio Code](https://code.visualstudio.com).\n\nUse the following [`launch.json`](https://code.visualstudio.com/docs/editor/debugging#_launch-configurations) configuration file:\n```\n{\n  \"version\": \"0.2.0\",\n  \"configurations\": [\n    {\n      \"name\": \"Debug CRA Tests\",\n      \"type\": \"node\",\n      \"request\": \"launch\",\n      \"runtimeExecutable\": \"${workspaceRoot}/node_modules/.bin/react-scripts\",      \n      \"args\": [\n        \"test\",\n        \"--runInBand\",\n        \"--no-cache\",\n        \"--env=jsdom\"\n      ],\n      \"cwd\": \"${workspaceRoot}\",\n      \"protocol\": \"inspector\",\n      \"console\": \"integratedTerminal\",\n      \"internalConsoleOptions\": \"neverOpen\"\n    }\n  ]\n}\n```\n\n## Developing Components in Isolation\n\nUsually, in an app, you have a lot of UI components, and each of them has many different states.\nFor an example, a simple button component could have following states:\n\n* In a regular state, with a text label.\n* In the disabled mode.\n* In a loading state.\n\nUsually, it’s hard to see these states without running a sample app or some examples.\n\nCreate 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**.\n\n![Storybook for React Demo](http://i.imgur.com/7CIAWpB.gif)\n\nYou 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.\n\n### Getting Started with Storybook\n\nStorybook 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.\n\nFirst, install the following npm package globally:\n\n```sh\nnpm install -g @storybook/cli\n```\n\nThen, run the following command inside your app’s directory:\n\n```sh\ngetstorybook\n```\n\nAfter that, follow the instructions on the screen.\n\nLearn more about React Storybook:\n\n* Screencast: [Getting Started with React Storybook](https://egghead.io/lessons/react-getting-started-with-react-storybook)\n* [GitHub Repo](https://github.com/storybooks/storybook)\n* [Documentation](https://storybook.js.org/basics/introduction/)\n* [Snapshot Testing UI](https://github.com/storybooks/storybook/tree/master/addons/storyshots) with Storybook + addon/storyshot\n\n### Getting Started with Styleguidist\n\nStyleguidist 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.\n\nFirst, install Styleguidist:\n\n```sh\nnpm install --save react-styleguidist\n```\n\nAlternatively you may use `yarn`:\n\n```sh\nyarn add react-styleguidist\n```\n\nThen, add these scripts to your `package.json`:\n\n```diff\n   \"scripts\": {\n+    \"styleguide\": \"styleguidist server\",\n+    \"styleguide:build\": \"styleguidist build\",\n     \"start\": \"react-scripts start\",\n```\n\nThen, run the following command inside your app’s directory:\n\n```sh\nnpm run styleguide\n```\n\nAfter that, follow the instructions on the screen.\n\nLearn more about React Styleguidist:\n\n* [GitHub Repo](https://github.com/styleguidist/react-styleguidist)\n* [Documentation](https://react-styleguidist.js.org/docs/getting-started.html)\n\n## Publishing Components to npm\n\nCreate React App doesn't provide any built-in functionality to publish a component to npm. If you're ready to extract a component from your project so other people can use it, we recommend moving it to a separate directory outside of your project and then using a tool like [nwb](https://github.com/insin/nwb#react-components-and-libraries) to prepare it for publishing.\n\n## Making a Progressive Web App\n\nBy default, the production build is a fully functional, offline-first\n[Progressive Web App](https://developers.google.com/web/progressive-web-apps/).\n\nProgressive Web Apps are faster and more reliable than traditional web pages, and provide an engaging mobile experience:\n\n * All static site assets are cached so that your page loads fast on subsequent visits, regardless of network connectivity (such as 2G or 3G). Updates are downloaded in the background.\n * Your app will work regardless of network state, even if offline. This means your users will be able to use your app at 10,000 feet and on the subway.\n * On mobile devices, your app can be added directly to the user's home screen, app icon and all. You can also re-engage users using web **push notifications**. This eliminates the need for the app store.\n\nThe [`sw-precache-webpack-plugin`](https://github.com/goldhand/sw-precache-webpack-plugin)\nis integrated into production configuration,\nand it will take care of generating a service worker file that will automatically\nprecache all of your local assets and keep them up to date as you deploy updates.\nThe service worker will use a [cache-first strategy](https://developers.google.com/web/fundamentals/instant-and-offline/offline-cookbook/#cache-falling-back-to-network)\nfor handling all requests for local assets, including the initial HTML, ensuring\nthat your web app is reliably fast, even on a slow or unreliable network.\n\n### Opting Out of Caching\n\nIf you would prefer not to enable service workers prior to your initial\nproduction deployment, then remove the call to `registerServiceWorker()`\nfrom [`src/index.js`](src/index.js).\n\nIf you had previously enabled service workers in your production deployment and\nhave decided that you would like to disable them for all your existing users,\nyou can swap out the call to `registerServiceWorker()` in\n[`src/index.js`](src/index.js) first by modifying the service worker import:\n```javascript\nimport { unregister } from './registerServiceWorker';\n```\nand then call `unregister()` instead.\nAfter the user visits a page that has `unregister()`,\nthe service worker will be uninstalled. Note that depending on how `/service-worker.js` is served,\nit may take up to 24 hours for the cache to be invalidated.\n\n### Offline-First Considerations\n\n1. Service workers [require HTTPS](https://developers.google.com/web/fundamentals/getting-started/primers/service-workers#you_need_https),\nalthough to facilitate local testing, that policy\n[does not apply to `localhost`](http://stackoverflow.com/questions/34160509/options-for-testing-service-workers-via-http/34161385#34161385).\nIf your production web server does not support HTTPS, then the service worker\nregistration will fail, but the rest of your web app will remain functional.\n\n1. Service workers are [not currently supported](https://jakearchibald.github.io/isserviceworkerready/)\nin all web browsers. Service worker registration [won't be attempted](src/registerServiceWorker.js)\non browsers that lack support.\n\n1. The service worker is only enabled in the [production environment](#deployment),\ne.g. the output of `npm run build`. It's recommended that you do not enable an\noffline-first service worker in a development environment, as it can lead to\nfrustration when previously cached assets are used and do not include the latest\nchanges you've made locally.\n\n1. If you *need* to test your offline-first service worker locally, build\nthe application (using `npm run build`) and run a simple http server from your\nbuild directory. After running the build script, `create-react-app` will give\ninstructions for one way to test your production build locally and the [deployment instructions](#deployment) have\ninstructions for using other methods. *Be sure to always use an\nincognito window to avoid complications with your browser cache.*\n\n1. If possible, configure your production environment to serve the generated\n`service-worker.js` [with HTTP caching disabled](http://stackoverflow.com/questions/38843970/service-worker-javascript-update-frequency-every-24-hours).\nIf that's not possible—[GitHub Pages](#github-pages), for instance, does not\nallow you to change the default 10 minute HTTP cache lifetime—then be aware\nthat if you visit your production site, and then revisit again before\n`service-worker.js` has expired from your HTTP cache, you'll continue to get\nthe previously cached assets from the service worker. If you have an immediate\nneed to view your updated production deployment, performing a shift-refresh\nwill temporarily disable the service worker and retrieve all assets from the\nnetwork.\n\n1. Users aren't always familiar with offline-first web apps. It can be useful to\n[let the user know](https://developers.google.com/web/fundamentals/instant-and-offline/offline-ux#inform_the_user_when_the_app_is_ready_for_offline_consumption)\nwhen the service worker has finished populating your caches (showing a \"This web\napp works offline!\" message) and also let them know when the service worker has\nfetched the latest updates that will be available the next time they load the\npage (showing a \"New content is available; please refresh.\" message). Showing\nthis messages is currently left as an exercise to the developer, but as a\nstarting point, you can make use of the logic included in [`src/registerServiceWorker.js`](src/registerServiceWorker.js), which\ndemonstrates which service worker lifecycle events to listen for to detect each\nscenario, and which as a default, just logs appropriate messages to the\nJavaScript console.\n\n1. By default, the generated service worker file will not intercept or cache any\ncross-origin traffic, like HTTP [API requests](#integrating-with-an-api-backend),\nimages, or embeds loaded from a different domain. If you would like to use a\nruntime caching strategy for those requests, you can [`eject`](#npm-run-eject)\nand then configure the\n[`runtimeCaching`](https://github.com/GoogleChrome/sw-precache#runtimecaching-arrayobject)\noption in the `SWPrecacheWebpackPlugin` section of\n[`webpack.config.prod.js`](../config/webpack.config.prod.js).\n\n### Progressive Web App Metadata\n\nThe default configuration includes a web app manifest located at\n[`public/manifest.json`](public/manifest.json), that you can customize with\ndetails specific to your web application.\n\nWhen a user adds a web app to their homescreen using Chrome or Firefox on\nAndroid, the metadata in [`manifest.json`](public/manifest.json) determines what\nicons, names, and branding colors to use when the web app is displayed.\n[The Web App Manifest guide](https://developers.google.com/web/fundamentals/engage-and-retain/web-app-manifest/)\nprovides more context about what each field means, and how your customizations\nwill affect your users' experience.\n\n## Analyzing the Bundle Size\n\n[Source map explorer](https://www.npmjs.com/package/source-map-explorer) analyzes\nJavaScript bundles using the source maps. This helps you understand where code\nbloat is coming from.\n\nTo add Source map explorer to a Create React App project, follow these steps:\n\n```sh\nnpm install --save source-map-explorer\n```\n\nAlternatively you may use `yarn`:\n\n```sh\nyarn add source-map-explorer\n```\n\nThen in `package.json`, add the following line to `scripts`:\n\n```diff\n   \"scripts\": {\n+    \"analyze\": \"source-map-explorer build/static/js/main.*\",\n     \"start\": \"react-scripts start\",\n     \"build\": \"react-scripts build\",\n     \"test\": \"react-scripts test --env=jsdom\",\n```\n\nThen to analyze the bundle run the production build then run the analyze\nscript.\n\n```\nnpm run build\nnpm run analyze\n```\n\n## Deployment\n\n`npm run build` creates a `build` directory with a production build of your app. Set up your favorite HTTP server so that a visitor to your site is served `index.html`, and requests to static paths like `/static/js/main.\u003chash\u003e.js` are served with the contents of the `/static/js/main.\u003chash\u003e.js` file.\n\n### Static Server\n\nFor environments using [Node](https://nodejs.org/), the easiest way to handle this would be to install [serve](https://github.com/zeit/serve) and let it handle the rest:\n\n```sh\nnpm install -g serve\nserve -s build\n```\n\nThe last command shown above will serve your static site on the port **5000**. Like many of [serve](https://github.com/zeit/serve)’s internal settings, the port can be adjusted using the `-p` or `--port` flags.\n\nRun this command to get a full list of the options available:\n\n```sh\nserve -h\n```\n\n### Other Solutions\n\nYou don’t necessarily need a static server in order to run a Create React App project in production. It works just as fine integrated into an existing dynamic one.\n\nHere’s a programmatic example using [Node](https://nodejs.org/) and [Express](http://expressjs.com/):\n\n```javascript\nconst express = require('express');\nconst path = require('path');\nconst app = express();\n\napp.use(express.static(path.join(__dirname, 'build')));\n\napp.get('/', function (req, res) {\n  res.sendFile(path.join(__dirname, 'build', 'index.html'));\n});\n\napp.listen(9000);\n```\n\nThe choice of your server software isn’t important either. Since Create React App is completely platform-agnostic, there’s no need to explicitly use Node.\n\nThe `build` folder with static assets is the only output produced by Create React App.\n\nHowever this is not quite enough if you use client-side routing. Read the next section if you want to support URLs like `/todos/42` in your single-page app.\n\n### Serving Apps with Client-Side Routing\n\nIf you use routers that use the HTML5 [`pushState` history API](https://developer.mozilla.org/en-US/docs/Web/API/History_API#Adding_and_modifying_history_entries) under the hood (for example, [React Router](https://github.com/ReactTraining/react-router) with `browserHistory`), many static file servers will fail. For example, if you used React Router with a route for `/todos/42`, the development server will respond to `localhost:3000/todos/42` properly, but an Express serving a production build as above will not.\n\nThis is because when there is a fresh page load for a `/todos/42`, the server looks for the file `build/todos/42` and does not find it. The server needs to be configured to respond to a request to `/todos/42` by serving `index.html`. For example, we can amend our Express example above to serve `index.html` for any unknown paths:\n\n```diff\n app.use(express.static(path.join(__dirname, 'build')));\n\n-app.get('/', function (req, res) {\n+app.get('/*', function (req, res) {\n   res.sendFile(path.join(__dirname, 'build', 'index.html'));\n });\n```\n\nIf you’re using [Apache HTTP Server](https://httpd.apache.org/), you need to create a `.htaccess` file in the `public` folder that looks like this:\n\n```\n    Options -MultiViews\n    RewriteEngine On\n    RewriteCond %{REQUEST_FILENAME} !-f\n    RewriteRule ^ index.html [QSA,L]\n```\n\nIt will get copied to the `build` folder when you run `npm run build`. \n\nIf you’re using [Apache Tomcat](http://tomcat.apache.org/), you need to follow [this Stack Overflow answer](https://stackoverflow.com/a/41249464/4878474).\n\nNow requests to `/todos/42` will be handled correctly both in development and in production.\n\nOn a production build, and in a browser that supports [service workers](https://developers.google.com/web/fundamentals/getting-started/primers/service-workers),\nthe service worker will automatically handle all navigation requests, like for\n`/todos/42`, by serving the cached copy of your `index.html`. This\nservice worker navigation routing can be configured or disabled by\n[`eject`ing](#npm-run-eject) and then modifying the\n[`navigateFallback`](https://github.com/GoogleChrome/sw-precache#navigatefallback-string)\nand [`navigateFallbackWhitelist`](https://github.com/GoogleChrome/sw-precache#navigatefallbackwhitelist-arrayregexp)\noptions of the `SWPreachePlugin` [configuration](../config/webpack.config.prod.js).\n\nWhen users install your app to the homescreen of their device the default configuration will make a shortcut to `/index.html`. This may not work for client-side routers which expect the app to be served from `/`. Edit the web app manifest at [`public/manifest.json`](public/manifest.json) and change `start_url` to match the required URL scheme, for example:\n\n```js\n  \"start_url\": \".\",\n```\n\n### Building for Relative Paths\n\nBy default, Create React App produces a build assuming your app is hosted at the server root.\u003cbr\u003e\nTo override this, specify the `homepage` in your `package.json`, for example:\n\n```js\n  \"homepage\": \"http://mywebsite.com/relativepath\",\n```\n\nThis will let Create React App correctly infer the root path to use in the generated HTML file.\n\n**Note**: If you are using `react-router@^4`, you can root `\u003cLink\u003e`s using the `basename` prop on any `\u003cRouter\u003e`.\u003cbr\u003e\nMore information [here](https://reacttraining.com/react-router/web/api/BrowserRouter/basename-string).\u003cbr\u003e\n\u003cbr\u003e\nFor example:\n```js\n\u003cBrowserRouter basename=\"/calendar\"/\u003e\n\u003cLink to=\"/today\"/\u003e // renders \u003ca href=\"/calendar/today\"\u003e\n```\n\n#### Serving the Same Build from Different Paths\n\n\u003eNote: this feature is available with `react-scripts@0.9.0` and higher.\n\nIf you are not using the HTML5 `pushState` history API or not using client-side routing at all, it is unnecessary to specify the URL from which your app will be served. Instead, you can put this in your `package.json`:\n\n```js\n  \"homepage\": \".\",\n```\n\nThis will make sure that all the asset paths are relative to `index.html`. You will then be able to move your app from `http://mywebsite.com` to `http://mywebsite.com/relativepath` or even `http://mywebsite.com/relative/path` without having to rebuild it.\n\n### [Azure](https://azure.microsoft.com/)\n\nSee [this](https://medium.com/@to_pe/deploying-create-react-app-on-microsoft-azure-c0f6686a4321) blog post on how to deploy your React app to Microsoft Azure.\n\nSee [this](https://medium.com/@strid/host-create-react-app-on-azure-986bc40d5bf2#.pycfnafbg) blog post or [this](https://github.com/ulrikaugustsson/azure-appservice-static) repo for a way to use automatic deployment to Azure App Service.\n\n### [Firebase](https://firebase.google.com/)\n\nInstall the Firebase CLI if you haven’t already by running `npm install -g firebase-tools`. Sign up for a [Firebase account](https://console.firebase.google.com/) and create a new project. Run `firebase login` and login with your previous created Firebase account.\n\nThen run the `firebase init` command from your project’s root. You need to choose the **Hosting: Configure and deploy Firebase Hosting sites** and choose the Firebase project you created in the previous step. You will need to agree with `database.rules.json` being created, choose `build` as the public directory, and also agree to **Configure as a single-page app** by replying with `y`.\n\n```sh\n    === Project Setup\n\n    First, let's associate this project directory with a Firebase project.\n    You can create multiple project aliases by running firebase use --add,\n    but for now we'll just set up a default project.\n\n    ? What Firebase project do you want to associate as default? Example app (example-app-fd690)\n\n    === Database Setup\n\n    Firebase Realtime Database Rules allow you to define how your data should be\n    structured and when your data can be read from and written to.\n\n    ? What file should be used for Database Rules? database.rules.json\n    ✔  Database Rules for example-app-fd690 have been downloaded to database.rules.json.\n    Future modifications to database.rules.json will update Database Rules when you run\n    firebase deploy.\n\n    === Hosting Setup\n\n    Your public directory is the folder (relative to your project directory) that\n    will contain Hosting assets to uploaded with firebase deploy. If you\n    have a build process for your assets, use your build's output directory.\n\n    ? What do you want to use as your public directory? build\n    ? Configure as a single-page app (rewrite all urls to /index.html)? Yes\n    ✔  Wrote build/index.html\n\n    i  Writing configuration info to firebase.json...\n    i  Writing project information to .firebaserc...\n\n    ✔  Firebase initialization complete!\n```\n\nIMPORTANT: you need to set proper HTTP caching headers for `service-worker.js` file in `firebase.json` file or you will not be able to see changes after first deployment ([issue #2440](https://github.com/facebookincubator/create-react-app/issues/2440)). It should be added inside `\"hosting\"` key like next:\n\n```\n{\n  \"hosting\": {\n    ...\n    \"headers\": [\n      {\"source\": \"/service-worker.js\", \"headers\": [{\"key\": \"Cache-Control\", \"value\": \"no-cache\"}]}\n    ]\n    ...\n```\n\nNow, after you create a production build with `npm run build`, you can deploy it by running `firebase deploy`.\n\n```sh\n    === Deploying to 'example-app-fd690'...\n\n    i  deploying database, hosting\n    ✔  database: rules ready to deploy.\n    i  hosting: preparing build directory for upload...\n    Uploading: [==============================          ] 75%✔  hosting: build folder uploaded successfully\n    ✔  hosting: 8 files uploaded successfully\n    i  starting release process (may take several minutes)...\n\n    ✔  Deploy complete!\n\n    Project Console: https://console.firebase.google.com/project/example-app-fd690/overview\n    Hosting URL: https://example-app-fd690.firebaseapp.com\n```\n\nFor more information see [Add Firebase to your JavaScript Project](https://firebase.google.com/docs/web/setup).\n\n### [GitHub Pages](https://pages.github.com/)\n\n\u003eNote: this feature is available with `react-scripts@0.2.0` and higher.\n\n#### Step 1: Add `homepage` to `package.json`\n\n**The step below is important!**\u003cbr\u003e\n**If you skip it, your app will not deploy correctly.**\n\nOpen your `package.json` and add a `homepage` field for your project:\n\n```json\n  \"homepage\": \"https://myusername.github.io/my-app\",\n```\n\nor for a GitHub user page:\n\n```json\n  \"homepage\": \"https://myusername.github.io\",\n```\n\nCreate React App uses the `homepage` field to determine the root URL in the built HTML file.\n\n#### Step 2: Install `gh-pages` and add `deploy` to `scripts` in `package.json`\n\nNow, whenever you run `npm run build`, you will see a cheat sheet with instructions on how to deploy to GitHub Pages.\n\nTo publish it at [https://myusername.github.io/my-app](https://myusername.github.io/my-app), run:\n\n```sh\nnpm install --save gh-pages\n```\n\nAlternatively you may use `yarn`:\n\n```sh\nyarn add gh-pages\n```\n\nAdd the following scripts in your `package.json`:\n\n```diff\n  \"scripts\": {\n+   \"predeploy\": \"npm run build\",\n+   \"deploy\": \"gh-pages -d build\",\n    \"start\": \"react-scripts start\",\n    \"build\": \"react-scripts build\",\n```\n\nThe `predeploy` script will run automatically before `deploy` is run.\n\nIf you are deploying to a GitHub user page instead of a project page you'll need to make two\nadditional modifications:\n\n1. First, change your repository's source branch to be any branch other than **master**.\n1. Additionally, tweak your `package.json` scripts to push deployments to **master**:\n```diff\n  \"scripts\": {\n    \"predeploy\": \"npm run build\",\n-   \"deploy\": \"gh-pages -d build\",\n+   \"deploy\": \"gh-pages -b master -d build\",\n```\n\n#### Step 3: Deploy the site by running `npm run deploy`\n\nThen run:\n\n```sh\nnpm run deploy\n```\n\n#### Step 4: Ensure your project’s settings use `gh-pages`\n\nFinally, make sure **GitHub Pages** option in your GitHub project settings is set to use the `gh-pages` branch:\n\n\u003cimg src=\"http://i.imgur.com/HUjEr9l.png\" width=\"500\" alt=\"gh-pages branch setting\"\u003e\n\n#### Step 5: Optionally, configure the domain\n\nYou can configure a custom domain with GitHub Pages by adding a `CNAME` file to the `public/` folder.\n\n#### Notes on client-side routing\n\nGitHub Pages doesn’t support routers that use the HTML5 `pushState` history API under the hood (for example, React Router using `browserHistory`). This is because when there is a fresh page load for a url like `http://user.github.io/todomvc/todos/42`, where `/todos/42` is a frontend route, the GitHub Pages server returns 404 because it knows nothing of `/todos/42`. If you want to add a router to a project hosted on GitHub Pages, here are a couple of solutions:\n\n* You could switch from using HTML5 history API to routing with hashes. If you use React Router, you can switch to `hashHistory` for this effect, but the URL will be longer and more verbose (for example, `http://user.github.io/todomvc/#/todos/42?_k=yknaj`). [Read more](https://reacttraining.com/react-router/web/api/Router) about different history implementations in React Router.\n* Alternatively, you can use a trick to teach GitHub Pages to handle 404 by redirecting to your `index.html` page with a special redirect parameter. You would need to add a `404.html` file with the redirection code to the `build` folder before deploying your project, and you’ll need to add code handling the redirect parameter to `index.html`. You can find a detailed explanation of this technique [in this guide](https://github.com/rafrex/spa-github-pages).\n\n#### Troubleshooting\n\n##### \"/dev/tty: No such a device or address\"\n\nIf, when deploying, you get `/dev/tty: No such a device or address` or a similar error, try the follwing:\n\n1. Create a new [Personal Access Token](https://github.com/settings/tokens)\n2. `git remote set-url origin https://\u003cuser\u003e:\u003ctoken\u003e@github.com/\u003cuser\u003e/\u003crepo\u003e` .\n3. Try `npm run deploy again`\n\n### [Heroku](https://www.heroku.com/)\n\nUse the [Heroku Buildpack for Create React App](https://github.com/mars/create-react-app-buildpack).\u003cbr\u003e\nYou can find instructions in [Deploying React with Zero Configuration](https://blog.heroku.com/deploying-react-with-zero-configuration).\n\n#### Resolving Heroku Deployment Errors\n\nSometimes `npm run build` works locally but fails during deploy via Heroku. Following are the most common cases.\n\n##### \"Module not found: Error: Cannot resolve 'file' or 'directory'\"\n\nIf you get something like this:\n\n```\nremote: Failed to create a production build. Reason:\nremote: Module not found: Error: Cannot resolve 'file' or 'directory'\nMyDirectory in /tmp/build_1234/src\n```\n\nIt means you need to ensure that the lettercase of the file or directory you `import` matches the one you see on your filesystem or on GitHub.\n\nThis is important because Linux (the operating system used by Heroku) is case sensitive. So `MyDirectory` and `mydirectory` are two distinct directories and thus, even though the project builds locally, the difference in case breaks the `import` statements on Heroku remotes.\n\n##### \"Could not find a required file.\"\n\nIf you exclude or ignore necessary files from the package you will see a error similar this one:\n\n```\nremote: Could not find a required file.\nremote:   Name: `index.html`\nremote:   Searched in: /tmp/build_a2875fc163b209225122d68916f1d4df/public\nremote:\nremote: npm ERR! Linux 3.13.0-105-generic\nremote: npm ERR! argv \"/tmp/build_a2875fc163b209225122d68916f1d4df/.heroku/node/bin/node\" \"/tmp/build_a2875fc163b209225122d68916f1d4df/.heroku/node/bin/npm\" \"run\" \"build\"\n```\n\nIn this case, ensure that the file is there with the proper lettercase and that’s not ignored on your local `.gitignore` or `~/.gitignore_global`.\n\n### [Netlify](https://www.netlify.com/)\n\n**To do a manual deploy to Netlify’s CDN:**\n\n```sh\nnpm install netlify-cli -g\nnetlify deploy\n```\n\nChoose `build` as the path to deploy.\n\n**To setup continuous delivery:**\n\nWith this setup Netlify will build and deploy when you push to git or open a pull request:\n\n1. [Start a new netlify project](https://app.netlify.com/signup)\n2. Pick your Git hosting service and select your repository\n3. Set `yarn build` as the build command and `build` as the publish directory\n4. Click `Deploy site`\n\n**Support for client-side routing:**\n\nTo support `pushState`, make sure to create a `public/_redirects` file with the following rewrite rules:\n\n```\n/*  /index.html  200\n```\n\nWhen you build the project, Create React App will place the `public` folder contents into the build output.\n\n### [Now](https://zeit.co/now)\n\nNow offers a zero-configuration single-command deployment. You can use `now` to deploy your app for free.\n\n1. Install the `now` command-line tool either via the recommended [desktop tool](https://zeit.co/download) or via node with `npm install -g now`.\n\n2. Build your app by running `npm run build`.\n\n3. Move into the build directory by running `cd build`.\n\n4. Run `now --name your-project-name` from within the build directory. You will see a **now.sh** URL in your output like this:\n\n    ```\n    \u003e Ready! https://your-project-name-tpspyhtdtk.now.sh (copied to clipboard)\n    ```\n\n    Paste that URL into your browser when the build is complete, and you will see your deployed app.\n\nDetails are available in [this article.](https://zeit.co/blog/unlimited-static)\n\n### [S3](https://aws.amazon.com/s3) and [CloudFront](https://aws.amazon.com/cloudfront/)\n\nSee this [blog post](https://medium.com/@omgwtfmarc/deploying-create-react-app-to-s3-or-cloudfront-48dae4ce0af) on how to deploy your React app to Amazon Web Services S3 and CloudFront.\n\n### [Surge](https://surge.sh/)\n\nInstall the Surge CLI if you haven’t already by running `npm install -g surge`. Run the `surge` command and log in you or create a new account.\n\nWhen asked about the project path, make sure to specify the `build` folder, for example:\n\n```sh\n       project path: /path/to/project/build\n```\n\nNote that in order to support routers that use HTML5 `pushState` API, you may want to rename the `index.html` in your build folder to `200.html` before deploying to Surge. This [ensures that every URL falls back to that file](https://surge.sh/help/adding-a-200-page-for-client-side-routing).\n\n## Advanced Configuration\n\nYou can adjust various development and production settings by setting environment variables in your shell or with [.env](#adding-development-environment-variables-in-env).\n\nVariable | Development | Production | Usage\n:--- | :---: | :---: | :---\nBROWSER | :white_check_mark: | :x: | By default, Create React App will open the default system browser, favoring Chrome on macOS. Specify a [browser](https://github.com/sindresorhus/opn#app) to override this behavior, or set it to `none` to disable it completely. If you need to customize the way the browser is launched, you can specify a node script instead. Any arguments passed to `npm start` will also be passed to this script, and the url where your app is served will be the last argument. Your script's file name must have the `.js` extension.\nHOST | :white_check_mark: | :x: | By default, the development web server binds to `localhost`. You may use this variable to specify a different host.\nPORT | :white_check_mark: | :x: | By default, the development web server will attempt to listen on port 3000 or prompt you to attempt the next available port. You may use this variable to specify a different port.\nHTTPS | :white_check_mark: | :x: | When set to `true`, Create React App will run the development server in `https` mode.\nPUBLIC_URL | :x: | :white_check_mark: | Create React App assumes your application is hosted at the serving web server's root or a subpath as specified in [`package.json` (`homepage`)](#building-for-relative-paths). Normally, Create React App ignores the hostname. You may use this variable to force assets to be referenced verbatim to the url you provide (hostname included). This may be particularly useful when using a CDN to host your application.\nCI | :large_orange_diamond: | :white_check_mark: | When set to `true`, Create React App treats warnings as failures in the build. It also makes the test runner non-watching. Most CIs set this flag by default.\nREACT_EDITOR | :white_check_mark: | :x: | When an app crashes in development, you will see an error overlay with clickable stack trace. When you click on it, Create React App will try to determine the editor you are using based on currently running processes, and open the relevant source file. You can [send a pull request to detect your editor of choice](https://github.com/facebookincubator/create-react-app/issues/2636). Setting this environment variable overrides the automatic detection. If you do it, make sure your systems [PATH](https://en.wikipedia.org/wiki/PATH_(variable)) environment variable points to your editor’s bin folder. You can also set it to `none` to disable it completely.\nCHOKIDAR_USEPOLLING | :white_check_mark: | :x: | When set to `true`, the watcher runs in polling mode, as necessary inside a VM. Use this option if `npm start` isn't detecting changes.\nGENERATE_SOURCEMAP | :x: | :white_check_mark: | When set to `false`, source maps are not generated for a production build. This solves OOM issues on some smaller machines.\nNODE_PATH | :white_check_mark: |  :white_check_mark: | Same as [`NODE_PATH` in Node.js](https://nodejs.org/api/modules.html#modules_loading_from_the_global_folders), but only relative folders are allowed. Can be handy for emulating a monorepo setup by setting `NODE_PATH=src`.\n\n## Troubleshooting\n\n### `npm start` doesn’t detect changes\n\nWhen you save a file while `npm start` is running, the browser should refresh with the updated code.\u003cbr\u003e\nIf this doesn’t happen, try one of the following workarounds:\n\n* If your project is in a Dropbox folder, try moving it out.\n* If the watcher doesn’t see a file called `index.js` and you’re referencing it by the folder name, you [need to restart the watcher](https://github.com/facebookincubator/create-react-app/issues/1164) due to a Webpack bug.\n* Some editors like Vim and IntelliJ have a “safe write” feature that currently breaks the watcher. You will need to disable it. Follow the instructions in [“Adjusting Your Text Editor”](https://webpack.js.org/guides/development/#adjusting-your-text-editor).\n* If your project path contains parentheses, try moving the project to a path without them. This is caused by a [Webpack watcher bug](https://github.com/webpack/watchpack/issues/42).\n* On Linux and macOS, you might need to [tweak system settings](https://github.com/webpack/docs/wiki/troubleshooting#not-enough-watchers) to allow more watchers.\n* If the project runs inside a virtual machine such as (a Vagrant provisioned) VirtualBox, create an `.env` file in your project directory if it doesn’t exist, and add `CHOKIDAR_USEPOLLING=true` to it. This ensures that the next time you run `npm start`, the watcher uses the polling mode, as necessary inside a VM.\n\nIf none of these solutions help please leave a comment [in this thread](https://github.com/facebookincubator/create-react-app/issues/659).\n\n### `npm test` hangs on macOS Sierra\n\nIf you run `npm test` and the console gets stuck after printing `react-scripts test --env=jsdom` to the console there might be a problem with your [Watchman](https://facebook.github.io/watchman/) installation as described in [facebookincubator/create-react-app#713](https://github.com/facebookincubator/create-react-app/issues/713).\n\nWe recommend deleting `node_modules` in your project and running `npm install` (or `yarn` if you use it) first. If it doesn't help, you can try one of the numerous workarounds mentioned in these issues:\n\n* [facebook/jest#1767](https://github.com/facebook/jest/issues/1767)\n* [facebook/watchman#358](https://github.com/facebook/watchman/issues/358)\n* [ember-cli/ember-cli#6259](https://github.com/ember-cli/ember-cli/issues/6259)\n\nIt is reported that installing Watchman 4.7.0 or newer fixes the issue. If you use [Homebrew](http://brew.sh/), you can run these commands to update it:\n\n```\nwatchman shutdown-server\nbrew update\nbrew reinstall watchman\n```\n\nYou can find [other installation methods](https://facebook.github.io/watchman/docs/install.html#build-install) on the Watchman documentation page.\n\nIf this still doesn’t help, try running `launchctl unload -F ~/Library/LaunchAgents/com.github.facebook.watchman.plist`.\n\nThere are also reports that *uninstalling* Watchman fixes the issue. So if nothing else helps, remove it from your system and try again.\n\n### `npm run build` exits too early\n\nIt is reported that `npm run build` can fail on machines with limited memory and no swap space, which is common in cloud environments. Even with small projects this command can increase RAM usage in your system by hundreds of megabytes, so if you have less than 1 GB of available memory your build is likely to fail with the following message:\n\n\u003e  The build failed because the process exited too early. This probably means the system ran out of memory or someone called `kill -9` on the process.\n\nIf you are completely sure that you didn't terminate the process, consider [adding some swap space](https://www.digitalocean.com/community/tutorials/how-to-add-swap-on-ubuntu-14-04) to the machine you’re building on, or build the project locally.\n\n### `npm run build` fails on Heroku\n\nThis may be a problem with case sensitive filenames.\nPlease refer to [this section](#resolving-heroku-deployment-errors).\n\n### Moment.js locales are missing\n\nIf you use a [Moment.js](https://momentjs.com/), you might notice that only the English locale is available by default. This is because the locale files are large, and you probably only need a subset of [all the locales provided by Moment.js](https://momentjs.com/#multiple-locale-support).\n\nTo add a specific Moment.js locale to your bundle, you need to import it explicitly.\u003cbr\u003e\nFor example:\n\n```js\nimport moment from 'moment';\nimport 'moment/locale/fr';\n```\n\nIf import multiple locales this way, you can later switch between them by calling `moment.locale()` with the locale name:\n\n```js\nimport moment from 'moment';\nimport 'moment/locale/fr';\nimport 'moment/locale/es';\n\n// ...\n\nmoment.locale('fr');\n```\n\nThis will only work for locales that have been explicitly imported before.\n\n### `npm run build` fails to minify\n\nSome third-party packages don't compile their code to ES5 before publishing to npm. This often causes problems in the ecosystem because neither browsers (except for most modern versions) nor some tools currently support all ES6 features. We recommend to publish code on npm as ES5 at least for a few more years.\n\n\u003cbr\u003e\nTo resolve this:\n\n1. Open an issue on the dependency's issue tracker and ask that the package be published pre-compiled.\n  * Note: Create React App can consume both CommonJS and ES modules. For Node.js compatibility, it is recommended that the main entry point is CommonJS. However, they can optionally provide an ES module entry point with the `module` field in `package.json`. Note that **even if a library provides an ES Modules version, it should still precompile other ES6 features to ES5 if it intends to support older browsers**.\n\n2. Fork the package and publish a corrected version yourself. \n\n3. If the dependency is small enough, copy it to your `src/` folder and treat it as application code.\n\nIn the future, we might start automatically compiling incompatible third-party modules, but it is not currently supported. This approach would also slow down the production builds.\n\n## Alternatives to Ejecting\n\n[Ejecting](#npm-run-eject) lets you customize anything, but from that point on you have to maintain the configuration and scripts yourself. This can be daunting if you have many similar projects. In such cases instead of ejecting we recommend to *fork* `react-scripts` and any other packages you need. [This article](https://auth0.com/blog/how-to-configure-create-react-app/) dives into how to do it in depth. You can find more discussion in [this issue](https://github.com/facebookincubator/create-react-app/issues/682).\n\n## Something Missing?\n\nIf you have ideas for more “How To” recipes that should be on this page, [let us know](https://github.com/facebookincubator/create-react-app/issues) or [contribute some!](https://github.com/facebookincubator/create-react-app/edit/master/packages/react-scripts/template/README.md)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnomangul%2Freact-course","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnomangul%2Freact-course","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnomangul%2Freact-course/lists"}