# react-batched-updates

> Cross platform unstable_batchedUpdates

Latest version **1.1.0** (published 2021-08-10) · MIT license · 0 weekly downloads

## Install

```sh
npm install react-batched-updates
pnpm add react-batched-updates
yarn add react-batched-updates
bun add react-batched-updates
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.0 |
| Published | 2021-08-10 |
| First published | 2021-04-02 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 7.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 3 |
| Author | Alec Larson |
| Maintainers | aleclarson |

## Links

- npm: https://www.npmjs.com/package/react-batched-updates
- Repository: https://github.com/alloc/react-batched-updates
- Homepage: https://github.com/alloc/react-batched-updates#readme
- Issues: https://github.com/alloc/react-batched-updates/issues
- npm.io page: https://npm.io/package/react-batched-updates

## Recent versions

- 1.1.0 (latest) — 2021-08-10
- 1.0.1 — 2021-04-02
- 1.0.0 — 2021-04-02

## README

# react-batched-updates

[![npm](https://img.shields.io/npm/v/react-batched-updates.svg)](https://www.npmjs.com/package/react-batched-updates)
[![Code style: Prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg)](https://github.com/prettier/prettier)
[![Donate](https://img.shields.io/badge/Donate-PayPal-green.svg)](https://paypal.me/alecdotbiz)

> Cross platform unstable_batchedUpdates

&nbsp;

## Usage

```ts
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.

```ts
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`.

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

setBatchedUpdates(act)
```

---
_Source: https://npm.io/package/react-batched-updates · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
