Make "Component Specs and Lifecycle" more readable
Andreas Savvides committed
Sep 14, 2015 at 18:43 UTC
c207ab29018aebe7f1fe1297f734a0b8d2081492
1 file changed
+14
-6
docs/docs/ref-03-component-specs.md
+14
-6
@@ -129,7 +129,9 @@ If you want to integrate with other JavaScript frameworks, set timers using `set
129
### Updating: componentWillReceiveProps
130
131
```javascript
132
-componentWillReceiveProps(object nextProps)
132
+componentWillReceiveProps(
133
+ object nextProps
134
+)
135
```
136
137
Invoked when a component is receiving new props. This method is not called for the initial render.
@@ -152,7 +154,9 @@ componentWillReceiveProps: function(nextProps) {
154
### Updating: shouldComponentUpdate
155
156
```javascript
155
-boolean shouldComponentUpdate(object nextProps, object nextState)
157
+boolean shouldComponentUpdate(
158
+ object nextProps, object nextState
159
+)
160
```
161
162
Invoked before rendering when new props or state are being received. This method is not called for the initial render or when `forceUpdate` is used.
@@ -166,9 +170,9 @@ shouldComponentUpdate: function(nextProps, nextState) {
170
}
171
```
172
169
-If `shouldComponentUpdate` returns false, then `render()` will be completely skipped until the next state change. (In addition, `componentWillUpdate` and `componentDidUpdate` will not be called.)
173
+If `shouldComponentUpdate` returns false, then `render()` will be completely skipped until the next state change. In addition, `componentWillUpdate` and `componentDidUpdate` will not be called.
174
171
-By default, `shouldComponentUpdate` always returns true to prevent subtle bugs when `state` is mutated in place, but if you are careful to always treat `state` as immutable and to read only from `props` and `state` in `render()` then you can override `shouldComponentUpdate` with an implementation that compares the old props and state to their replacements.
175
+By default, `shouldComponentUpdate` always returns `true` to prevent subtle bugs when `state` is mutated in place, but if you are careful to always treat `state` as immutable and to read only from `props` and `state` in `render()` then you can override `shouldComponentUpdate` with an implementation that compares the old props and state to their replacements.
176
177
If performance is a bottleneck, especially with dozens or hundreds of components, use `shouldComponentUpdate` to speed up your app.
178
@@ -176,7 +180,9 @@ If performance is a bottleneck, especially with dozens or hundreds of components
180
### Updating: componentWillUpdate
181
182
```javascript
179
-componentWillUpdate(object nextProps, object nextState)
183
+componentWillUpdate(
184
+ object nextProps, object nextState
185
+)
186
```
187
188
Invoked immediately before rendering when new props or state are being received. This method is not called for the initial render.
@@ -191,7 +197,9 @@ Use this as an opportunity to perform preparation before an update occurs.
197
### Updating: componentDidUpdate
198
199
```javascript
194
-componentDidUpdate(object prevProps, object prevState)
200
+componentDidUpdate(
201
+ object prevProps, object prevState
202
+)
203
```
204
205
Invoked immediately after the component's updates are flushed to the DOM. This method is not called for the initial render.