Reactive utilities

batch

Edit this page

What changed

In Solid 1.x, batch was used to group multiple signal updates so downstream computations only ran once. In Solid 2.0, this happens automatically — all signal setter calls batch their downstream updates until the next microtask.


Replacement: flush()

If you need to force synchronous application of pending updates (e.g., to read the DOM immediately after a state change), use flush():

import { flush } from "solid-js"
setCount(1)
setText("hello")
flush() // synchronously applies all pending updates

flush() should be used sparingly — in most cases, allowing the default microtask batching is preferred.


Migration

// 1.x
import { batch } from "solid-js"
batch(() => {
setA(1)
setB(2)
setC(3)
})
// 2.0 — just set the signals, batching is automatic
setA(1)
setB(2)
setC(3)
// If you need synchronous flush:
flush()
Report an issue with this page