react-batched-updates
Cross platform unstable_batchedUpdates
Last updated 5 years ago by aleclarson .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ npm install react-batched-updates 
SYNC missed versions from official npm registry.

react-batched-updates

npm Code style: Prettier Donate

Cross platform unstable_batchedUpdates

 

Usage

import { batchedUpdates } from 'react-batched-updates'

batchedUpdates(() => {
  // Any setState calls are batched, instead of triggering 
  // multiple render passes.
})

You should call setBatchedUpdates or else batchedUpdates will be ineffective. Except for React Native users, where the bundler prefers cjs/index.native.js, a module that requires react-native to achieve zero configuration.

import { setBatchedUpdates } from 'react-batched-updates'
import { unstable_batchedUpdates } from 'react-dom'

// Both react-native and react-dom have this export.
setBatchedUpdates(unstable_batchedUpdates)

In test environments, you can usually replace unstable_batchedUpdates with act.

import { setBatchedUpdates } from 'react-batched-updates'
import { act } from '@testing-library/react'

setBatchedUpdates(act)

Current Tags

  • 1.1.0                                ...           latest (5 years ago)

3 Versions

  • 1.1.0                                ...           5 years ago
  • 1.0.1                                ...           6 years ago
  • 1.0.0                                ...           6 years ago
Maintainers (1)
Downloads
Total 9
Today 0
This Week 0
This Month 3
Last Day 0
Last Week 2
Last Month 6
Dependencies (0)
None
Dev Dependencies (3)
Dependents (1)

© 2010 - cnpmjs.org x YWFE | Home | YWFE