tezvyn:

Jotai Derived Atoms: Computed State from Other Atoms

Source: jotai.orgintermediate

Think of a derived atom like a spreadsheet formula: its value is computed from other atoms. Use it for reactive values like a cart total from item prices. The footgun: the `get` in your read function is reactive, but the `get` in your write function.

A derived atom in Jotai is like a spreadsheet formula: its value is automatically calculated from other atoms. Instead of manually syncing state, you define how one piece of state depends on others. Use it for a cart total from item prices or a filtered list. The footgun: `get` in the `read` function creates reactive dependencies, but `get` in the `write` function does not, which can cause unexpected non-reactive behavior if misused.

Read the original → jotai.org

Get five bites like this every day.

Tezvyn delivers a daily feed of 60-second tech bites with quizzes to lock in what you learn.

Jotai Derived Atoms: Computed State from Other Atoms · Tezvyn