Overview
ThewithComputed extension enhances an atom with computed functionality, allowing you to derive state based on reactive dependencies. It’s a powerful way to add computed behavior to existing atoms without converting them to computed atoms.
Type Signature
Parameters
function
required
A function that computes the new state based on the current state.Parameters:
state: The current state of the atom
object
Examples
Basic Computed for Atom
Manual Update with Computed Fallback
Combining Multiple Computations
Conditional Computed
Transform State
Sync Atom with External Source
Computed with Dependencies Check
Use Cases
Default Value Pattern
Fallback Chain
Derived State with Manual Override
Related
- computed - Create pure computed atoms
- withChangeHook - React to state changes
- atom - Base atom primitive