@samitouri / QOS-React-2 / commits / f98112f24d

Make "Component API" more readable

Andreas Savvides committed Sep 14, 2015 at 18:23 UTC f98112f24d306c16079e3b0beb90cb08751c3fac
1 file changed +21 -7
docs/docs/ref-02-component-api.md
+21 -7
@@ -14,13 +14,16 @@ Instances of a React Component are created internally in React when rendering. T
14 ### setState
15
16 ```javascript
17 -setState(function|object nextState[, function callback])
17 +setState(
18 + function|object nextState,
19 + [function callback]
20 +)
21 ```
22 Performs a shallow merge of nextState into current state. This is the primary method you use to trigger UI updates from event handlers and server request callbacks.
23
24 The first argument can be an object (containing zero or more keys to update) or a function (of state and props) that returns an object containing keys to update.
25
23 -Here is the simple object usage...
26 +Here is the simple object usage:
27
28 ```javascript
29 setState({mykey: 'my new value'});
@@ -50,7 +53,10 @@ The second (optional) parameter is a callback function that will be executed onc
53 ### replaceState
54
55 ```javascript
53 -replaceState(object nextState[, function callback])
56 +replaceState(
57 + object nextState,
58 + [function callback]
59 +)
60 ```
61
62 Like `setState()` but deletes any pre-existing state keys that are not in nextState.
@@ -63,7 +69,9 @@ Like `setState()` but deletes any pre-existing state keys that are not in nextSt
69 ### forceUpdate
70
71 ```javascript
66 -forceUpdate([function callback])
72 +forceUpdate(
73 + [function callback]
74 +)
75 ```
76
77 By default, when your component's state or props change, your component will re-render. However, if these change implicitly (eg: data deep within an object changes without changing the object itself) or if your `render()` method depends on some other data, you can tell React that it needs to re-run `render()` by calling `forceUpdate()`.
@@ -94,7 +102,7 @@ If this component has been mounted into the DOM, this returns the corresponding
102 bool isMounted()
103 ```
104
97 -`isMounted()` returns true if the component is rendered into the DOM, false otherwise. You can use this method to guard asynchronous calls to `setState()` or `forceUpdate()`.
105 +`isMounted()` returns `true` if the component is rendered into the DOM, `false` otherwise. You can use this method to guard asynchronous calls to `setState()` or `forceUpdate()`.
106
107 > Note:
108 >
@@ -104,7 +112,10 @@ bool isMounted()
112 ### setProps
113
114 ```javascript
107 -setProps(object nextProps[, function callback])
115 +setProps(
116 + object nextProps,
117 + [function callback]
118 +)
119 ```
120
121 When you're integrating with an external JavaScript application you may want to signal a change to a React component rendered with `React.render()`.
@@ -122,7 +133,10 @@ Calling `setProps()` on a root-level component will change its properties and tr
133 ### replaceProps
134
135 ```javascript
125 -replaceProps(object nextProps[, function callback])
136 +replaceProps(
137 + object nextProps,
138 + [function callback]
139 +)
140 ```
141
142 Like `setProps()` but deletes any pre-existing props instead of merging the two objects.