@samitouri / QOS-React-2 / commits / 1219663e9a

Docs: added note about setState() side-effects

Julen Ruiz Aizpuru committed Jul 30, 2014 at 13:49 UTC 1219663e9a63862d39538c75f4a60993d5d4d48a
1 file changed +2
docs/docs/ref-02-component-api.md
+2
@@ -27,6 +27,8 @@ Merges nextState with the current state. This is the primary method you use to t
27 > `setState()` does not immediately mutate `this.state` but creates a pending state transition. Accessing `this.state` after calling this method can potentially return the existing value.
28 >
29 > There is no guarantee of synchronous operation of calls to `setState` and calls may be batched for performance gains.
30 +>
31 +> `setState()` will always trigger a re-render unless conditional rendering logic is implemented in `shouldComponentUpdate()`. If mutable objects are being used and the logic cannot be implemented in `shouldComponentUpdate()`, calling `setState()` only when the new state differs from the previous state will avoid unnecessary re-renders.
32
33
34 ### replaceState