Skip to content

Sharing reactive state with child using context, child not seeing changes to counter.count (bug in official demo from docs) #16229

Closed
@TylerRick

Description

@TylerRick

Describe the bug

I was just reading about "Using context with state" on https://svelte.dev/docs/svelte/context#Using-context-with-state and I tried out the linked demo ... but it didn't work! Clicking increment does not update the counter in the Child component. What am I missing? As far I can tell, everything done in the demo looks correct and "should" work.

So as far I can tell, this is a Svelte bug, yes?

And if it's not a Svelte bug, then it would be very instructional to find out what is wrong with this usage.

Interestingly, adding $inspect(counter) to Child.svelte is enough to trick it into working. But that's obviously not the proper solution.

Reproduction

See demo linked to from https://svelte.dev/docs/svelte/context#Using-context-with-state

Logs

System Info

N/A

Severity

annoyance

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions