You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-[Integrating with a Node Backend](#integrating-with-a-node-backend)
22
+
-[Deploying](#deploying)
23
+
-[Something Missing?](#something-missing)
25
24
26
25
## Sending Feedback
27
26
@@ -90,9 +89,7 @@ Instead, it will copy all the configuration files and the transitive dependencie
90
89
91
90
You 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.
92
91
93
-
## Recipes
94
-
95
-
### Displaying Lint Output in the Editor
92
+
## Displaying Lint Output in the Editor
96
93
97
94
>Note: this feature is available with `[email protected]` and higher.
We recognize that this is suboptimal, but it is currently required due to the way we hide the ESLint dependency. The ESLint team is already [working on a solution to this](https://github.com/eslint/eslint/issues/3458) so this may become unnecessary in a couple of months.
132
129
133
-
###Installing a Dependency
130
+
## Installing a Dependency
134
131
135
132
The 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`:
136
133
137
134
```
138
135
npm install --save <library-name>
139
136
```
140
137
141
-
###Importing a Component
138
+
## Importing a Component
142
139
143
140
This project setup supports ES6 modules thanks to Babel.
144
141
While you can still use `require()` and `module.exports`, we encourage you to use [`import` and `export`](http://exploringjs.com/es6/ch_modules.html) instead.
145
142
146
143
For example:
147
144
148
-
####`Button.js`
145
+
### `Button.js`
149
146
150
147
```js
151
148
importReact, { Component } from'react';
@@ -159,7 +156,8 @@ class Button extends Component {
159
156
exportdefaultButton; // Don’t forget to use export default!
160
157
```
161
158
162
-
#### `DangerButton.js`
159
+
### `DangerButton.js`
160
+
163
161
164
162
```js
165
163
importReact, { Component } from'react';
@@ -186,19 +184,19 @@ Learn more about ES6 modules:
This project setup uses [Webpack](https://webpack.github.io/) 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**:
192
190
193
-
####`Button.css`
191
+
### `Button.css`
194
192
195
193
```css
196
194
.Button {
197
195
padding: 20px;
198
196
}
199
197
```
200
198
201
-
####`Button.js`
199
+
### `Button.js`
202
200
203
201
```js
204
202
importReact, { Component } from'react';
@@ -218,7 +216,7 @@ In development, expressing dependencies this way allows your styles to be reload
218
216
219
217
If 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.
220
218
221
-
###Post-Processing CSS
219
+
## Post-Processing CSS
222
220
223
221
This 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.
224
222
@@ -251,7 +249,7 @@ becomes this:
251
249
252
250
There is currently no support for preprocessors such as Less, or for sharing variables across CSS files.
253
251
254
-
###Adding Images and Fonts
252
+
## Adding Images and Fonts
255
253
256
254
With Webpack, using static assets like images and fonts works similarly to CSS.
257
255
@@ -287,33 +285,33 @@ Please be advised that this is also a custom feature of Webpack.
287
285
288
286
**It is not required for React** but many people enjoy it (and React Native uses a similar mechanism for images). However it may not be portable to some other environments, such as Node.js and Browserify. If you prefer to reference static assets in a more traditional way outside the module system, please let us know [in this issue](https://github.com/facebookincubator/create-react-app/issues/28), and we will consider support for this.
289
287
290
-
###Adding Bootstrap
288
+
## Adding Bootstrap
291
289
292
290
You 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:
293
291
294
-
**Step 1.**Install React Bootstrap and Bootstrap from NPM. React Bootstrap does not include Bootstrap CSS so this needs to be installed as well.
292
+
Install React Bootstrap and Bootstrap from NPM. React Bootstrap does not include Bootstrap CSS so this needs to be installed as well:
295
293
296
294
```
297
295
npm install react-bootstrap --save
298
296
npm install bootstrap@3 --save
299
297
```
300
298
301
-
**Step 2.**Import Bootstrap CSS and optionally Bootstrap theme CSS in the ```index.js``` file.
299
+
Import Bootstrap CSS and optionally Bootstrap theme CSS in the ```src/index.js``` file:
302
300
303
301
```js
304
302
import'bootstrap/dist/css/bootstrap.css';
305
303
import'bootstrap/dist/css/bootstrap-theme.css';
306
304
```
307
305
308
-
**Step 3.**Import required React Bootstrap components within ```App.js``` file or your custom component files.
306
+
Import required React Bootstrap components within ```src/App.js``` file or your custom component files:
Now 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.
315
313
316
-
###Adding Flow
314
+
## Adding Flow
317
315
318
316
Flow typing is currently [not supported out of the box](https://github.com/facebookincubator/create-react-app/issues/72) with the default `.flowconfig` generated by Flow. If you run it, you might get errors like this:
We will consider integrating more tightly with Flow in the future so that you don’t have to do this.
371
369
372
-
### Adding Custom Environment Variables
370
+
## Adding Custom Environment Variables
373
371
374
372
> Note: this feature is available with `react-scripts@0.3.0` and higher.
375
373
@@ -401,13 +399,15 @@ render() {
401
399
The above form is looking for a variable called `REACT_APP_SECRET_CODE` from the environment. In order to consume this
402
400
value, we need to have it defined in the environment:
403
401
404
-
#### Windows Cmd
402
+
### Windows (cmd.exe)
405
403
406
404
```cmd
407
-
set REACT_APP_SECRET_CODE=abcdef&&npm start
405
+
set REACT_APP_SECRET_CODE=abcdef&&npm start
408
406
```
409
407
410
-
#### Bash/Unix shells
408
+
(Note: the lack of whitespace is intentional.)
409
+
410
+
### Linux, OS X (Bash)
411
411
412
412
```bash
413
413
REACT_APP_SECRET_CODE=abcdef npm start
@@ -437,13 +437,13 @@ if (process.env.NODE_ENV !== 'production') {
437
437
}
438
438
```
439
439
440
-
### Integrating with a Node Backend
440
+
## Integrating with a Node Backend
441
441
442
442
Check out [this tutorial](https://www.fullstackreact.com/articles/using-create-react-app-with-a-server/) for instructions on integrating an app with a Node backend running on another port, and using `fetch()` to access it. You can find the companion GitHub repository [here](https://github.com/fullstackreact/food-lookup-demo).
443
443
444
-
### Deploying
444
+
## Deploying
445
445
446
-
#### GitHub Pages
446
+
### GitHub Pages
447
447
448
448
>Note: this feature is available with `react-scripts@0.2.0` and higher.
449
449
@@ -475,10 +475,10 @@ Note that GitHub Pages doesn't support routers that use the HTML5 `pushState` hi
475
475
* 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://github.com/reactjs/react-router/blob/master/docs/guides/Histories.md#histories) about different history implementations in React Router.
476
476
* 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 ofthis technique [inthis guide](https://github.com/rafrex/spa-github-pages).
477
477
478
-
#### Heroku
478
+
### Heroku
479
479
480
480
Use the [Heroku Buildpack for create-react-app](https://github.com/mars/create-react-app-buildpack).
481
481
482
-
### Something Missing?
482
+
## Something Missing?
483
483
484
484
If 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/template/README.md)
0 commit comments