10 Fun Facts About Create React App
A few things you know and a few you probably don’t

React is a JavaScript library for building user interfaces. It’s one of the most popular libraries for building single-page applications. Create React App is a quick way to scaffold a React project. In this way, you focus on code, rather than building tools.
Fact #1: You Can Create a Fully-Fledged Project With a Single Command
This magic command can be invoked by one of three ways:
npx create-react-app my-app
npm init react-app my-app
yarn create react-app my-appFacebook pledges that all of its underlying pieces — Webpack, Babel, ESLint, Jest, etc — work together seamlessly.
Out of the box, the following scripts are set up:
npm start: Runs the app in development mode, and open http://localhost:3000 to view it in the browser.npm run build: Builds the app for production to the build folder.
The build is minified and ready to be deployed.npm test: Runs the test watcher in an interactive mode. It runs tests related to files changed since the last commit.Fact #2: React Projects Can be Started With a Specific Template
The previous commands can be customized with a specific template:
npx create-react-app my-app --template [template-name]
npm init react-app my-app --template [template-name]
yarn create react-app my-app --template [template-name]If you want to start with a React project with TypeScript, simply use the template, cra-template-typescript. The default template is cra-template.
If you want to take advantage of the community resources, try this website. There are currently 170 templates available.

Fact #3: One Dependency Is the First Philosophy of Create React App, and This Build Dependency Is Not in the devDependencies Section
One Dependency is the first of three Create React App philosophies. Can you find this build dependency in the following package.json?
{
"name": "my-react-app",
"dependencies": {
"react": "^16.12.0",
"react-dom": "^16.12.0",
"react-scripts": "3.2.0"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},In package.json, we see three dependencies and nodevDependencies. Where is this one dependency?
It is react-scripts!
According to NPM dependencies definition, the build dependency, react-scripts, should be a devDependency. However, it is in the dependencies section along with react and react-dom.
In fact, react-scripts was a devDependency. For some practical reason, Facebook made it a dependency since react-scripts 1.0.8.
Fact #4: No Configuration Required Is the Second Philosophy of Create React App — But It’s Not Zero Configuration
Create React App has set up a reasonably good configuration for both development and production builds. A developer can focus on writing code. It’s possible to not configure anything.
The following is the out-of-box source code tree. We actually find one configure file, .gitignore, which is used for github’s source code version control.
my-react-app/
node_modules/
public/
favicon.ico
index.html
logo192.png
logo512.png
manifest.json
robots.txt
src/
App.css
App.js
App.test.js
index.css
index.js
logo.svg
serviceWorker.js
.gitignore
package-lock.json
package.json
README.mdFact #5: No Lock-In Is the Third Philosophy of Create React App — And You Don’t Have to Eject a Project to Customize a Setup
No Lock-In is the opposite of one dependency. It allows you to eject the preconfigured settings for customization. Run a single command, react-scripts eject, and all the configuration and build dependencies will be moved directly into the project. The project is no longer one dependency. At this point, you’re on your own.
Does that sound scary?
Well, react-app-rewired comes to the rescue. It’s possible to rewire a project for customization, without ejecting it.
This can be achieved in three steps:
- Install
react-app-rewiredas adevDependency:npm install react-app-rewired --save-dev:
"devDependencies": {
"react-app-rewired": "^2.1.5"
}2. Create a config-overrides.js file in the root directory:
module.exports = (config, env) => {
//do stuff with the webpack config…
return config;
}3. Flip the existing calls in package.json from react-scripts to react-app-rewired (except eject):
{
"scripts": {
"start": "react-app-rewired start",
"build": "react-app-rewired build",
"test": "react-app-rewired test",
"eject": "react-scripts eject"
},
}Now you’re free to configure settings for Webpack, Babel, ESLint, Jest, etc.
Fact #6: “React-App-Rewired” Adds More Power by Configuring “Config-overrides.js”
In our React project development process, we took full advantage of react-app-rewired configuration capability.
Here are a few examples of how to use config-overrides.js:
Example 1: Resolving the issue whereby you have more than one copy of React in the same app, mentioned in my other article.
We use the monorepo lerna to structure micro-frontends’ multi-package repositories. Our application ends up with its own React dependency, as well as its dependency’s React devDependency. Usually, an application still works when there are multiple copies of packages. However, React breaks when it’s included twice, even if the versions are equal. The following example used an alias to resolve all React links to the application’s own copy.
const path = require('path');
module.exports = {
webpack: (config, env) => {
if (env === 'development') {
config.resolve.alias = {
react: path.resolve('node_modules/react'),
'react-dom': path.resolve('node_modules/react-dom'),
};
}
return config;
},
};Example 2: Resolve “How to load library source maps using webpack?” issue, mentioned in one of the solutions.
In the similar monorepo micro-frontends environment, a library source map is generated, but it is not loaded during the development debugger session. With the additional package, source-map-loader, the following code resolved the issue by setting the sourceMaps option to true.








