@samitouri / QOS-React-2 / commits / f3aac85d01
Fork 0

The library for web and native user interfaces.

Updated docs and check for truthiness

Change api docs to reflect presence of the new argument. In addition, callback was change to require only a "truthy" value.

ngavalas committed Jun 14, 2013 at 16:37 UTC f3aac85d01d87bca593170f6ae0935c9aaf9084c
2 files changed +6 -4
docs/docs/api.md
+4 -2
@@ -108,15 +108,17 @@ Transfer properties from this component to a target component that have not alre
108 #### setState
109
110 ```javascript
111 -setState(object nextState)
111 +setState(object nextState_[, function callback]_)
112 ```
113
114 -Merges nextState with the current state. This is the primary method you use to trigger UI updates from event handlers and server request callbacks.
114 +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.
115
116 **Note:** *NEVER* mutate `this.state` directly. As calling `setState()` afterwards may replace the mutation you made. Treat `this.state` as if it were immutable.
117
118 **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.
119
120 +**Note**: There is no guarantee of synchronous operation of calls to `setState` and calls may eventually be batched for performance gains.
121 +
122 #### replaceState
123
124 ```javascript
src/core/ReactCompositeComponent.js
+2 -2
@@ -538,8 +538,8 @@ var ReactCompositeComponentMixin = {
538 setState: function(partialState, callback) {
539 // Merge with `_pendingState` if it exists, otherwise with existing state.
540 this.replaceState(merge(this._pendingState || this.state, partialState));
541 - // If `callback` is callable, do it.
542 - typeof callback === 'function' && callback();
541 + // If `callback` is truthy, do it.
542 + callback && callback();
543 },
544
545 /**