batching strategy for react, taken from Facebook