SIGN IN SIGN UP
sveltejs / svelte UNCLAIMED

web development for the rest of us

0 0 70 JavaScript

docs: clarify context state getter pattern (#18226)

Closes #18022

This updates the context docs to show the getter pattern for state that
may be reassigned, such as primitive state. The new example passes a
function through context so children read the current value instead of
capturing the initial value.

This is a docs-only clarification and does not change runtime behavior.

Validation:

- `git diff --check`
- `pnpm exec prettier --check
documentation/docs/06-runtime/02-context.md`

Full `pnpm test`/`pnpm lint` were not run because this only changes
documentation.

---------

Co-authored-by: Rich Harris <hello@rich-harris.dev>
M
Mukunda Rao Katta committed
a63bf862c03d5c63b73e412f2ca952cb83d444d8
Parent: a5df661
Committed by GitHub <noreply@github.com> on 5/18/2026, 7:42:20 PM