Skip to content

Commit dc7facf

Browse files
committed
Prettify some more files
1 parent 30c0047 commit dc7facf

File tree

16 files changed

+270
-224
lines changed

16 files changed

+270
-224
lines changed

.prettierrc

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"singleQuote": false
3+
}

CHANGES.md

+136-136
Large diffs are not rendered by default.

CONTRIBUTING.md

+12-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Thanks for contributing, you rock!
22

3-
If you use our code, it is now *our* code.
3+
If you use our code, it is now _our_ code.
44

55
Please read https://reactjs.org/ and the Code of Conduct before opening an issue.
66

@@ -12,21 +12,25 @@ Please read https://reactjs.org/ and the Code of Conduct before opening an issue
1212
- [Development](#development)
1313

1414
<a name="bug"/></a>
15+
1516
## Think You Found a Bug?
1617

1718
Please provide a test case of some sort. Best is a pull request with a failing test. Next is a link to CodePen/JS Bin or repository that illustrates the bug. Finally, some copy/pastable code is acceptable.
1819

1920
<a name="api"/></a>
21+
2022
## Proposing New or Changed API?
2123

2224
Please provide thoughtful comments and some sample code. Proposals without substance will be closed.
2325

2426
<a name="attention"/></a>
27+
2528
## Issue Not Getting Attention?
2629

2730
If you need a bug fixed and nobody is fixing it, it is your responsibility to fix it. Issues with no activity for 30 days may be closed.
2831

2932
<a name="pr"/></a>
33+
3034
## Making a Pull Request?
3135

3236
Pull requests need only the :+1: of two or more collaborators to be merged; when the PR author is a collaborator, that counts as one.
@@ -51,12 +55,15 @@ The following steps will get you setup to contribute changes to this repo:
5155

5256
1. Fork the repo (click the <kbd>Fork</kbd> button at the top right of this page).
5357
2. Clone your fork locally.
58+
5459
```bash
5560
# in a terminal, cd to parent directory where you want your clone to be, then
5661
git clone https://github.com/<your_github_username>/react-router.git
5762
cd react-router
5863
```
64+
5965
3. Install dependencies and build. React Router uses `npm`, so you should too. If you install using `yarn`, unnecessary yarn lock files will be generated.
66+
6067
```bash
6168
npm install
6269
npm run build
@@ -73,6 +80,7 @@ React Router uses Lerna to manage the monorepo. Lerna sets up symlinks between t
7380
### Building
7481

7582
Calling `npm run build` from the root directory will build every package. If you want to build a specific package, you should `cd` into that directory.
83+
7684
```bash
7785
# build everything
7886
npm run build
@@ -84,18 +92,21 @@ npm run build
8492
### Testing
8593

8694
Calling `npm test` from the root directory will run **every** package's tests. If you want to run tests for a specific package, you should `cd` into that directory.
95+
8796
```bash
8897
# all tests
8998
npm test
9099
# react-router-dom tests
91100
cd packages/react-router-dom
92101
npm test
93102
```
103+
94104
React Router uses Jest to run its tests, so you can provide the `--watch` flag to automatically re-run tests when files change.
95105

96106
### Website
97107

98108
The code for the documentation website lives in the `website` directory. `cd` into there and call `npm start` to start a webpack dev server on `localhost:8080` that will watch for changes.
109+
99110
```bash
100111
cd website
101112
npm start

FAQ.md

+33-27
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
# Frequently Asked Questions
22

3-
This is a list of support questions that frequently show up in GitHub issues. This list is intended to minimize the frequency of this happening. The issues section is intended for bug reports, not developer support. Support questions should be asked at StackOverflow or in the Reactiflux chat.
3+
This is a list of support questions that frequently show up in GitHub issues. This list is intended to minimize the frequency of this happening. The issues section is intended for bug reports, not developer support. Support questions should be asked at StackOverflow or in the Reactiflux chat.
44

55
If there is a support question that you frequently see being asked, please open a PR to add it to this list.
66

7-
* [Why aren't my components updating when the location changes?](#why-arent-my-components-updating-when-the-location-changes)
8-
* [Why doesn't my application render after refreshing?](#why-doesnt-my-application-render-after-refreshing)
9-
* [Why doesn't my application work when loading nested routes?](#why-doesnt-my-application-work-when-loading-nested-routes)
10-
* [How do I access the `history` object outside of components?](#how-do-i-access-the-history-object-outside-of-components)
11-
* [How do I pass props to the component rendered by a `<Route>`?](#how-do-i-pass-props-to-the-component-rendered-by-a-route)
7+
- [Why aren't my components updating when the location changes?](#why-arent-my-components-updating-when-the-location-changes)
8+
- [Why doesn't my application render after refreshing?](#why-doesnt-my-application-render-after-refreshing)
9+
- [Why doesn't my application work when loading nested routes?](#why-doesnt-my-application-work-when-loading-nested-routes)
10+
- [How do I access the `history` object outside of components?](#how-do-i-access-the-history-object-outside-of-components)
11+
- [How do I pass props to the component rendered by a `<Route>`?](#how-do-i-pass-props-to-the-component-rendered-by-a-route)
1212

1313
### Why aren't my components updating when the location changes?
1414

@@ -19,13 +19,14 @@ React Router relies on updates propagating from your router component to every c
1919
If your application is hosted on a static file server, you need to use a `<HashRouter>` instead of a `<BrowserRouter>`.
2020

2121
```js
22-
import { HashRouter } from 'react-router-dom'
22+
import { HashRouter } from "react-router-dom";
2323

24-
ReactDOM.render((
24+
ReactDOM.render(
2525
<HashRouter>
2626
<App />
27-
</HashRouter>
28-
), holder)
27+
</HashRouter>,
28+
holder
29+
);
2930
```
3031

3132
When you load the root page of a website hosted on a static file server (e.g., `http://www.example.com`), a `<BrowserHistory>` might appear to work. However, this is only because when the browser makes the request for the root page, the server responds with the root `index.html` file.
@@ -45,9 +46,9 @@ However, you will end up with a blank screen if you were to refresh a non-root p
4546
This is not an issue when your server can respond to dynamic requests. In that situation, you can instruct the server to catch all requests and serve up the same `index.html` file.
4647

4748
```js
48-
app.get('*', (req, res) => {
49-
res.sendFile(path.resolve(__dirname, 'index.html'))
50-
})
49+
app.get("*", (req, res) => {
50+
res.sendFile(path.resolve(__dirname, "index.html"));
51+
});
5152
```
5253

5354
When you use a static server, your application should have just one `index.html` file.
@@ -75,6 +76,7 @@ If the `src` of the `<script>` tag that is used to load your application has a r
7576
<script src='static/js/bundle.js'></script>
7677
<script src='./static/js/bundle.js'></script>
7778
```
79+
7880
### How do I access the `history` object outside of components?
7981

8082
When you use the `<BrowserRouter>`, `<HashRouter>`, `<MemoryRouter>`, and `<NativeRouter>`, a `history` object will be created for you. This is convenient, and the `history` object is readily accessible from within your React components, but it can be a pain to use it outside of them. If you need to access a `history` object outside of your components, you will need to create your own `history` object (in its own module) and import it throughout your project.
@@ -83,23 +85,26 @@ If you do this, make sure that you use the generic `<Router>` component and not
8385

8486
```js
8587
// history.js
86-
import { createBrowserHistory } from 'history'
87-
export default createBrowserHistory()
88+
import { createBrowserHistory } from "history";
89+
export default createBrowserHistory();
8890
```
91+
8992
```js
9093
// index.js
91-
import { Router } from 'react-router-dom';
92-
import history from './history'
94+
import { Router } from "react-router-dom";
95+
import history from "./history";
9396

94-
ReactDOM.render((
97+
ReactDOM.render(
9598
<Router history={history}>
9699
<App />
97-
</Router>
98-
), document.getElementById('root'))
100+
</Router>,
101+
document.getElementById("root")
102+
);
99103
```
104+
100105
```js
101106
// nav.js
102-
import history from './history'
107+
import history from "./history";
103108

104109
export default function nav(loc) {
105110
history.push(loc);
@@ -116,11 +121,12 @@ If you need to pass props to the component rendered by a `<Route>`, you should u
116121

117122
```js
118123
const App = () => {
119-
const color = 'red'
124+
const color = "red";
120125
return (
121-
<Route path='/somewhere' render={(props) => (
122-
<MyComponent {...props} color={color} />
123-
)} />
124-
)
125-
}
126+
<Route
127+
path="/somewhere"
128+
render={props => <MyComponent {...props} color={color} />}
129+
/>
130+
);
131+
};
126132
```

ISSUE_TEMPLATE.md

+2
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,13 @@ Remove the template from below and provide thoughtful commentary *and code sampl
2121
-->
2222

2323
<!-- BUG TEMPLATE -->
24+
2425
## Version
2526

2627
**Please replace this sentence with the React Router version that you are using.**
2728

2829
## Test Case
30+
2931
https://codesandbox.io/s/7zwjlm2j3q
3032

3133
## Steps to reproduce

packages/react-router-config/README.md

+35-28
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ Then with a module bundler like [webpack](https://webpack.github.io/), use as yo
1717

1818
```js
1919
// using an ES6 transpiler, like babel
20-
import { matchRoutes, renderRoutes } from 'react-router-config'
20+
import { matchRoutes, renderRoutes } from "react-router-config";
2121

2222
// not using an ES6 transpiler
23-
var matchRoutes = require('react-router-config').matchRoutes
23+
var matchRoutes = require("react-router-config").matchRoutes;
2424
```
2525

2626
The UMD build is also available on [unpkg](https://unpkg.com):
@@ -52,23 +52,27 @@ Routes are objects with the same properties as a `<Route>` with a couple differe
5252

5353
```js
5454
const routes = [
55-
{ component: Root,
55+
{
56+
component: Root,
5657
routes: [
57-
{ path: '/',
58+
{
59+
path: "/",
5860
exact: true,
5961
component: Home
6062
},
61-
{ path: '/child/:id',
63+
{
64+
path: "/child/:id",
6265
component: Child,
6366
routes: [
64-
{ path: '/child/:id/grand-child',
67+
{
68+
path: "/child/:id/grand-child",
6569
component: GrandChild
6670
}
6771
]
6872
}
6973
]
7074
}
71-
]
75+
];
7276
```
7377

7478
**Note**: Just like `<Route>`, relative paths are not (yet) supported. When it is supported there, it will be supported here.
@@ -80,12 +84,13 @@ const routes = [
8084
Returns an array of matched routes.
8185

8286
#### Parameters
87+
8388
- routes - the route configuration
8489
- pathname - the [pathname](https://developer.mozilla.org/en-US/docs/Web/API/HTMLHyperlinkElementUtils/pathname) component of the url. This must be a decoded string representing the path.
8590

8691
```js
87-
import { matchRoutes } from 'react-router-config'
88-
const branch = matchRoutes(routes, '/child/23')
92+
import { matchRoutes } from "react-router-config";
93+
const branch = matchRoutes(routes, "/child/23");
8994
// using the routes shown earlier, this returns
9095
// [
9196
// routes[0],
@@ -99,8 +104,8 @@ Each item in the array contains two properties: `routes` and `match`.
99104
- `match`: The match object that also gets passed to `<Route>` render methods.
100105

101106
```js
102-
branch[0].match.url
103-
branch[0].match.isExact
107+
branch[0].match.url;
108+
branch[0].match.isExact;
104109
// etc.
105110
```
106111

@@ -191,63 +196,65 @@ Again, that's all pseudo-code. There are a lot of ways to do server rendering wi
191196
In order to ensure that matching outside of render with `matchRoutes` and inside of render result in the same branch, you must use `renderRoutes` instead of `<Route>` inside your components. You can render a `<Route>` still, but know that it will not be accounted for in `matchRoutes` outside of render.
192197

193198
```js
194-
import { renderRoutes } from 'react-router-config'
199+
import { renderRoutes } from "react-router-config";
195200

196201
const routes = [
197-
{ component: Root,
202+
{
203+
component: Root,
198204
routes: [
199-
{ path: '/',
205+
{
206+
path: "/",
200207
exact: true,
201208
component: Home
202209
},
203-
{ path: '/child/:id',
210+
{
211+
path: "/child/:id",
204212
component: Child,
205213
routes: [
206-
{ path: '/child/:id/grand-child',
214+
{
215+
path: "/child/:id/grand-child",
207216
component: GrandChild
208217
}
209218
]
210219
}
211220
]
212221
}
213-
]
222+
];
214223

215224
const Root = ({ route }) => (
216225
<div>
217226
<h1>Root</h1>
218227
{/* child routes won't render without this */}
219228
{renderRoutes(route.routes)}
220229
</div>
221-
)
230+
);
222231

223232
const Home = ({ route }) => (
224233
<div>
225234
<h2>Home</h2>
226235
</div>
227-
)
236+
);
228237

229238
const Child = ({ route }) => (
230239
<div>
231240
<h2>Child</h2>
232241
{/* child routes won't render without this */}
233-
{renderRoutes(route.routes, { someProp: 'these extra props are optional' })}
242+
{renderRoutes(route.routes, { someProp: "these extra props are optional" })}
234243
</div>
235-
)
244+
);
236245

237246
const GrandChild = ({ someProp }) => (
238247
<div>
239248
<h3>Grand Child</h3>
240249
<div>{someProp}</div>
241250
</div>
242-
)
243-
251+
);
244252

245-
ReactDOM.render((
253+
ReactDOM.render(
246254
<BrowserRouter>
247255
{/* kick it all off with the root route */}
248256
{renderRoutes(routes)}
249-
</BrowserRouter>
250-
), document.getElementById('root'))
251-
257+
</BrowserRouter>,
258+
document.getElementById("root")
259+
);
252260
```
253-

packages/react-router-dom/README.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@ Then with a module bundler like [webpack](https://webpack.github.io/), use as yo
1212

1313
```js
1414
// using ES6 modules
15-
import { BrowserRouter, Route, Link } from 'react-router-dom'
15+
import { BrowserRouter, Route, Link } from "react-router-dom";
1616

1717
// using CommonJS modules
18-
const BrowserRouter = require('react-router-dom').BrowserRouter
19-
const Route = require('react-router-dom').Route
20-
const Link = require('react-router-dom').Link
18+
const BrowserRouter = require("react-router-dom").BrowserRouter;
19+
const Route = require("react-router-dom").Route;
20+
const Link = require("react-router-dom").Link;
2121
```
2222

2323
The UMD build is also available on [unpkg](https://unpkg.com):

0 commit comments

Comments
 (0)