Closed
Description
React batches all component updates if they become dirty during an event-callback (events are also batched). However, this is not exposed for use with external events, such as setTimeout
, addEventHandler
, AJAX-replies, non-React DOM events or any other events, and it seems only natural that it should extend to those too.
I see two obvious solutions:
Export React.batchedUpdates(callback, param)
setTimeout(function() {
React.batchedUpdates(function() {
...
}.bind(this));
});
setTimeout(React.batchedUpdates.bind(null, function() {
...
}.bind(this));
Export a callback factory React.batchedCallback(callback, args...)
setTimeout(React.batchedCallback(function() {
...
}.bind(this));
Thoughts?
I'm guessing this belongs with #326