Skip to content

Commit 8cef20d

Browse files
authored
Flatten the recipes
1 parent 379cf5c commit 8cef20d

File tree

1 file changed

+39
-39
lines changed

1 file changed

+39
-39
lines changed

template/README.md

Lines changed: 39 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,18 @@ You can find the most recent version of this guide [here](https://github.com/fac
99
- [npm start](#npm-start)
1010
- [npm run build](#npm-run-build)
1111
- [npm run eject](#npm-run-eject)
12-
- [Recipes](#recipes)
13-
- [Displaying Lint Output in the Editor](#displaying-lint-output-in-the-editor)
14-
- [Installing a Dependency](#installing-a-dependency)
15-
- [Importing a Component](#importing-a-component)
16-
- [Adding a Stylesheet](#adding-a-stylesheet)
17-
- [Post-Processing CSS](#post-processing-css)
18-
- [Adding Images and Fonts](#adding-images-and-fonts)
19-
- [Adding Bootstrap](#adding-bootstrap)
20-
- [Adding Flow](#adding-flow)
21-
- [Adding Custom Environment Variables](#adding-custom-environment-variables)
22-
- [Integrating with a Node Backend](#integrating-with-a-node-backend)
23-
- [Deploying](#deploying)
24-
- [Something Missing?](#something-missing)
12+
- [Displaying Lint Output in the Editor](#displaying-lint-output-in-the-editor)
13+
- [Installing a Dependency](#installing-a-dependency)
14+
- [Importing a Component](#importing-a-component)
15+
- [Adding a Stylesheet](#adding-a-stylesheet)
16+
- [Post-Processing CSS](#post-processing-css)
17+
- [Adding Images and Fonts](#adding-images-and-fonts)
18+
- [Adding Bootstrap](#adding-bootstrap)
19+
- [Adding Flow](#adding-flow)
20+
- [Adding Custom Environment Variables](#adding-custom-environment-variables)
21+
- [Integrating with a Node Backend](#integrating-with-a-node-backend)
22+
- [Deploying](#deploying)
23+
- [Something Missing?](#something-missing)
2524

2625
## Sending Feedback
2726

@@ -90,9 +89,7 @@ Instead, it will copy all the configuration files and the transitive dependencie
9089

9190
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.
9291

93-
## Recipes
94-
95-
### Displaying Lint Output in the Editor
92+
## Displaying Lint Output in the Editor
9693

9794
>Note: this feature is available with `[email protected]` and higher.
9895
@@ -130,22 +127,22 @@ npm install -g eslint babel-eslint eslint-plugin-react eslint-plugin-import esli
130127

131128
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.
132129

133-
### Installing a Dependency
130+
## Installing a Dependency
134131

135132
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`:
136133

137134
```
138135
npm install --save <library-name>
139136
```
140137

141-
### Importing a Component
138+
## Importing a Component
142139

143140
This project setup supports ES6 modules thanks to Babel.
144141
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.
145142

146143
For example:
147144

148-
#### `Button.js`
145+
### `Button.js`
149146

150147
```js
151148
import React, { Component } from 'react';
@@ -159,7 +156,8 @@ class Button extends Component {
159156
export default Button; // Don’t forget to use export default!
160157
```
161158

162-
#### `DangerButton.js`
159+
### `DangerButton.js`
160+
163161

164162
```js
165163
import React, { Component } from 'react';
@@ -186,19 +184,19 @@ Learn more about ES6 modules:
186184
* [Exploring ES6: Modules](http://exploringjs.com/es6/ch_modules.html)
187185
* [Understanding ES6: Modules](https://leanpub.com/understandinges6/read#leanpub-auto-encapsulating-code-with-modules)
188186

189-
### Adding a Stylesheet
187+
## Adding a Stylesheet
190188

191189
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**:
192190

193-
#### `Button.css`
191+
### `Button.css`
194192

195193
```css
196194
.Button {
197195
padding: 20px;
198196
}
199197
```
200198

201-
#### `Button.js`
199+
### `Button.js`
202200

203201
```js
204202
import React, { Component } from 'react';
@@ -218,7 +216,7 @@ In development, expressing dependencies this way allows your styles to be reload
218216

219217
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.
220218

221-
### Post-Processing CSS
219+
## Post-Processing CSS
222220

223221
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.
224222

@@ -251,7 +249,7 @@ becomes this:
251249

252250
There is currently no support for preprocessors such as Less, or for sharing variables across CSS files.
253251

254-
### Adding Images and Fonts
252+
## Adding Images and Fonts
255253

256254
With Webpack, using static assets like images and fonts works similarly to CSS.
257255

@@ -287,33 +285,33 @@ Please be advised that this is also a custom feature of Webpack.
287285

288286
**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.
289287

290-
### Adding Bootstrap
288+
## Adding Bootstrap
291289

292290
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:
293291

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:
295293

296294
```
297295
npm install react-bootstrap --save
298296
npm install bootstrap@3 --save
299297
```
300298

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:
302300

303301
```js
304302
import 'bootstrap/dist/css/bootstrap.css';
305303
import 'bootstrap/dist/css/bootstrap-theme.css';
306304
```
307305

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:
309307

310308
```js
311309
import { Navbar, Jumbotron, Button } from 'react-bootstrap';
312310
```
313311

314312
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.
315313

316-
### Adding Flow
314+
## Adding Flow
317315

318316
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:
319317

@@ -369,7 +367,7 @@ module.name_mapper='^\(.*\)\.\(jpg\|png\|gif\|eot\|svg\|ttf\|woff\|woff2\|mp4\|w
369367
370368
We will consider integrating more tightly with Flow in the future so that you don’t have to do this.
371369
372-
### Adding Custom Environment Variables
370+
## Adding Custom Environment Variables
373371
374372
> Note: this feature is available with `react-scripts@0.3.0` and higher.
375373
@@ -401,13 +399,15 @@ render() {
401399
The above form is looking for a variable called `REACT_APP_SECRET_CODE` from the environment. In order to consume this
402400
value, we need to have it defined in the environment:
403401
404-
#### Windows Cmd
402+
### Windows (cmd.exe)
405403
406404
```cmd
407-
set REACT_APP_SECRET_CODE=abcdef && npm start
405+
set REACT_APP_SECRET_CODE=abcdef&&npm start
408406
```
409407
410-
#### Bash/Unix shells
408+
(Note: the lack of whitespace is intentional.)
409+
410+
### Linux, OS X (Bash)
411411
412412
```bash
413413
REACT_APP_SECRET_CODE=abcdef npm start
@@ -437,13 +437,13 @@ if (process.env.NODE_ENV !== 'production') {
437437
}
438438
```
439439
440-
### Integrating with a Node Backend
440+
## Integrating with a Node Backend
441441
442442
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).
443443
444-
### Deploying
444+
## Deploying
445445
446-
#### GitHub Pages
446+
### GitHub Pages
447447
448448
>Note: this feature is available with `react-scripts@0.2.0` and higher.
449449
@@ -475,10 +475,10 @@ Note that GitHub Pages doesn't support routers that use the HTML5 `pushState` hi
475475
* 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.
476476
* 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).
477477

478-
#### Heroku
478+
### Heroku
479479

480480
Use the [Heroku Buildpack for create-react-app](https://github.com/mars/create-react-app-buildpack).
481481

482-
### Something Missing?
482+
## Something Missing?
483483

484484
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

Comments
 (0)