|
24 | 24 |
|
25 | 25 | ## Naming |
26 | 26 |
|
27 | | - - **Extensions**: Use `.js` extension for React components. |
28 | | - - **Filename**: Use PascalCase for filenames. E.g., `ReservationCard.js`. |
| 27 | + - **Extensions**: Use `.jsx` extension for React components. |
| 28 | + - **Filename**: Use PascalCase for filenames. E.g., `ReservationCard.jsx`. |
29 | 29 | - **Reference Naming**: Use PascalCase for React components and camelCase for their instances: |
30 | 30 | ```javascript |
31 | 31 | // bad |
|
41 | 41 | const reservationItem = <ReservationCard />; |
42 | 42 | ``` |
43 | 43 |
|
44 | | - **Component Naming**: Use the filename as the component name. So `ReservationCard.js` should have a reference name of ReservationCard. However, for root components of a directory, use index.js as the filename and use the directory name as the component name: |
| 44 | + **Component Naming**: Use the filename as the component name. For example, `ReservationCard.jsx` should have a reference name of `ReservationCard`. However, for root components of a directory, use `index.jsx` as the filename and use the directory name as the component name: |
45 | 45 | ```javascript |
46 | 46 | // bad |
47 | | - const Footer = require('./Footer/Footer.js') |
| 47 | + const Footer = require('./Footer/Footer.jsx') |
48 | 48 |
|
49 | 49 | // bad |
50 | | - const Footer = require('./Footer/index.js') |
| 50 | + const Footer = require('./Footer/index.jsx') |
51 | 51 |
|
52 | 52 | // good |
53 | 53 | const Footer = require('./Footer') |
54 | 54 | ``` |
55 | 55 |
|
56 | 56 |
|
57 | 57 | ## Declaration |
58 | | - - Do not use displayName for naming components, instead name the component by reference. |
| 58 | + - Do not use displayName for naming components. Instead, name the component by reference. |
59 | 59 |
|
60 | 60 | ```javascript |
61 | 61 | // bad |
|
72 | 72 | ``` |
73 | 73 |
|
74 | 74 | ## Alignment |
75 | | - - Follow these alignment styles for js syntax |
| 75 | + - Follow these alignment styles for JS syntax |
76 | 76 |
|
77 | 77 | ```javascript |
78 | 78 | // bad |
|
98 | 98 | ``` |
99 | 99 |
|
100 | 100 | ## Quotes |
101 | | - - Always use double quotes (`"`) for JSX attributes, but single quotes for all other JavaScript. |
| 101 | + - Always use double quotes (`"`) for JSX attributes, but single quotes for all other JS. |
102 | 102 | ```javascript |
103 | 103 | // bad |
104 | 104 | <Foo bar='bar' /> |
|
197 | 197 | ``` |
198 | 198 |
|
199 | 199 | ## Methods |
200 | | - - Do not use underscore prefix for internal methods of a react component. |
| 200 | + - Do not use underscore prefix for internal methods of a React component. |
201 | 201 | ```javascript |
202 | 202 | // bad |
203 | 203 | React.createClass({ |
|
219 | 219 | ``` |
220 | 220 |
|
221 | 221 | ## Ordering |
222 | | - - Always follow the following order for methods in a react component: |
| 222 | + - Always follow the following order for methods in a React component: |
223 | 223 |
|
224 | 224 | 1. displayName |
225 | | - 2. mixins (as of React v0.13 mixins are deprecated) |
| 225 | + 2. mixins (as of React v0.13, mixins are deprecated) |
226 | 226 | 3. statics |
227 | 227 | 4. propTypes |
228 | 228 | 5. getDefaultProps |
|
0 commit comments