Skip to content

Commit

Permalink
Update docs versioning for 7.1
Browse files Browse the repository at this point in the history
  • Loading branch information
timdorr committed Jun 11, 2019
1 parent 316467a commit 3f0933c
Show file tree
Hide file tree
Showing 14 changed files with 1,284 additions and 23 deletions.
2 changes: 1 addition & 1 deletion website/siteConfig.js
Expand Up @@ -108,7 +108,7 @@ const siteConfig = {
* After that, 7.x will no longer appear in "pre-release" versions and we should remove this line
* More info: https://docusaurus.io/docs/en/versioning
*/
nextVersion: '7.1.0-alpha.5',
nextVersion: '',

gaTrackingId: 'UA-130598673-2'
}
Expand Down
35 changes: 35 additions & 0 deletions website/versioned_docs/version-7.1/api/batch.md
@@ -0,0 +1,35 @@
---
id: version-7.1-batch
title: batch
sidebar_label: batch()
hide_title: true
original_id: batch
---

# `batch()`

```js
batch(fn: Function)
```

React's `unstable_batchedUpdate()` API allows any React updates in an event loop tick to be batched together into a single render pass. React already uses this internally for its own event handler callbacks. This API is actually part of the renderer packages like ReactDOM and React Native, not the React core itself.

Since React-Redux needs to work in both ReactDOM and React Native environments, we've taken care of importing this API from the correct renderer at build time for our own use. We also now re-export this function publicly ourselves, renamed to `batch()`. You can use it to ensure that multiple actions dispatched outside of React only result in a single render update, like this:

```js
import { batch } from 'react-redux'

function myThunk() {
return (dispatch, getState) => {
// should only result in one combined re-render, not two
batch(() => {
dispatch(increment())
dispatch(increment())
})
}
}
```

## References

- [`unstable_batchedUpdate()` API from React](https://github.com/facebook/react/commit/b41883fc708cd24d77dcaa767cde814b50b457fe)

0 comments on commit 3f0933c

Please sign in to comment.