Skip to content
This repository was archived by the owner on Jan 26, 2019. It is now read-only.

Commit a829ca3

Browse files
authored
Tweak howto
1 parent cd8bae0 commit a829ca3

File tree

1 file changed

+26
-18
lines changed

1 file changed

+26
-18
lines changed

template/README.md

+26-18
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ 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-
- [How To](#how-to)
12+
- [Recipes](#recipes)
1313
- [Displaying Lint Output in the Editor](#displaying-lint-output-in-the-editor)
1414
- [Installing a Dependency](#installing-a-dependency)
1515
- [Importing a Component](#importing-a-component)
@@ -19,6 +19,7 @@ You can find the most recent version of this guide [here](https://github.com/fac
1919
- [Adding Bootstrap](#adding-bootstrap)
2020
- [Adding Flow](#adding-flow)
2121
- [Adding Custom Environment Variables](#adding-custom-environment-variables)
22+
- [Integrating with a Node Backend](#integrating-with-a-node-backend)
2223
- [Deploying](#deploying)
2324
- [Something Missing?](#something-missing)
2425

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

9091
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.
9192

92-
## How To
93+
## Recipes
9394

9495
### Displaying Lint Output in the Editor
9596

@@ -129,7 +130,6 @@ npm install -g eslint babel-eslint eslint-plugin-react eslint-plugin-import esli
129130

130131
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.
131132

132-
133133
### Installing a Dependency
134134

135135
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`:
@@ -317,7 +317,7 @@ Now you are ready to use the imported React Bootstrap components within your com
317317

318318
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:
319319

320-
```
320+
```js
321321
node_modules/fbjs/lib/Deferred.js.flow:60
322322
60: Promise.prototype.done.apply(this._promise, arguments);
323323
^^^^ property `done`. Property not found in
@@ -343,7 +343,7 @@ src/index.js:5
343343
344344
To fix this, change your `.flowconfig` to look like this:
345345
346-
```
346+
```ini
347347
[libs]
348348
./node_modules/fbjs/flow/lib
349349

@@ -362,7 +362,7 @@ Re-run flow, and you shouldn’t get any extra issues.
362362
363363
If you later `eject`, you’ll need to replace `react-scripts` references with the `<PROJECT_ROOT>` placeholder, for example:
364364
365-
```
365+
```ini
366366
module.name_mapper='^\(.*\)\.css$' -> '<PROJECT_ROOT>/config/flow/css'
367367
module.name_mapper='^\(.*\)\.\(jpg\|png\|gif\|eot\|svg\|ttf\|woff\|woff2\|mp4\|webm\)$' -> '<PROJECT_ROOT>/config/flow/file'
368368
```
@@ -386,13 +386,16 @@ First, you need to have environment variables defined, which can vary between OS
386386
consume a secret defined in the environment inside a `<form>`:
387387
388388
```jsx
389-
<h6>Hello, Admin!<h6>
390-
391-
<small>You are running this application in <strong>{process.env.NODE_ENV}</strong> mode.</small>
392-
393-
<form>
394-
<input type="hidden" defaultValue={process.env.REACT_APP_SECRET_CODE} />
395-
</form>
389+
render() {
390+
return (
391+
<div>
392+
<small>You are running this application in <b>{process.env.NODE_ENV}</b> mode.</small>
393+
<form>
394+
<input type="hidden" defaultValue={process.env.REACT_APP_SECRET_CODE} />
395+
</form>
396+
</div>
397+
);
398+
}
396399
```
397400
398401
The above form is looking for a variable called `REACT_APP_SECRET_CODE` from the environment. In order to consume this
@@ -418,11 +421,12 @@ variable will be set for you automatically. When you load the app in the browser
418421
its value set to `abcdef`, and the bold text will show the environment provided when using `npm start`:
419422
420423
```html
421-
<h6>Hello, Admin!</h6>
422-
<small>You are running this application in <strong>development</strong> mode.</small>
423-
<form>
424-
<input type="hidden" value="abcdef" />
425-
</form>
424+
<div>
425+
<small>You are running this application in <b>development</b> mode.</small>
426+
<form>
427+
<input type="hidden" value="abcdef" />
428+
</form>
429+
</div>
426430
```
427431
428432
Having access to the `NODE_ENV` is also useful for performing actions conditionally:
@@ -433,6 +437,10 @@ if (process.env.NODE_ENV !== 'production') {
433437
}
434438
```
435439
440+
### Integrating with a Node Backend
441+
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+
436444
### Deploying
437445
438446
#### GitHub Pages

0 commit comments

Comments
 (0)