Browse Source

Merge pull request #115 from spicyj/async-state

Batch together calls to setState, setProps, etc
main
Pete Hunt 12 years ago
parent
commit
c3bc59a526
  1. 6
      docs/api.md

6
docs/api.md

@ -109,15 +109,17 @@ Transfer properties from this component to a target component that have not alre
#### setState #### setState
```javascript ```javascript
setState(object nextState) setState(object nextState[, function callback])
``` ```
Merges nextState with the current state. This is the primary method you use to trigger UI updates from event handlers and server request callbacks. Merges nextState with the current state. This is the primary method you use to trigger UI updates from event handlers and server request callbacks. In addition, you can supply an optional callback function that is executed once `setState` is completed.
**Note:** *NEVER* mutate `this.state` directly. As calling `setState()` afterwards may replace the mutation you made. Treat `this.state` as if it were immutable. **Note:** *NEVER* mutate `this.state` directly. As calling `setState()` afterwards may replace the mutation you made. Treat `this.state` as if it were immutable.
**Note:** `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. **Note:** `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.
**Note**: There is no guarantee of synchronous operation of calls to `setState` and calls may eventually be batched for performance gains.
#### replaceState #### replaceState
```javascript ```javascript

Loading…
Cancel
Save