Skip to content

Svelte 5: Reading 'setContext'd prop in child causes children to be re-created #9503

@dooshiifox

Description

@dooshiifox

Describe the bug

Making a prop visible in a context, then reading that state inside a child (e.g., setContext('', { get exampleProp() { return exampleProp; }) -> getContext('').exampleProp) causes the snippet to be recreated. See repro and how Mounted child gets called every time show changes.

Passing through a store as a prop instead of a $state fixes it which is why its an annoyance and not blocking an upgrade.

Reproduction

https://svelte-5-preview.vercel.app/#H4sIAAAAAAAAA5VTwW7bMAz9FVbowQa85J7E6YZedtlpBXaYB9SVaUeYLAkSva4w_O8TJTtr19MOQUSK7-nxkZ5FrzQGcfg-C9OOKA7ik3OiEvTiOAi_UBPGONjJS86cgvTK0bkxDanRWU_wgIGg93aERuz2HO0yrhFcxT-NBOFin6GG20AtYdG3OmB5bMxp_5fRnJ4mImvAGqmV_FnPRQn1GYoVe8P_5ZIe_8opFUBO3qMh_QIz3y7MmFkyY1KXr4BbrBvx7Fvn0DciEeUKLqhnM2l9LZMXpbtY9Bm1tvDNet3dnFJ_Z34kHaI1o-1Ur7ATB_ITLtXVSS74TytnGJDurSH8TRWE6xmWzeDN2SM3l42dk_gKkt7oRZUaiJBotvPWhaJcq6U1wWrcaTsUjfhip0geO8yAregW-x4lFdn6OY3wH2TyXl5aM2AHymwMVdR34CCNieloef00gWt5VlFYHmhdAzsOd6_ajvQUjWtECYd0m3jC-_tq0zasyxUFr5mGPNLkTUofc255I2e_h4dL3B6tDPIW0QXjJmnnFcETynYKMU3QSokhYFiF75hvhd_bcYwpZQYuTIjAJ7JgLIHHDxHRoY-7DI-Me1wdY3ymu9ut-t58A_PHFbjNsyij9veL9mP5A_xqhhW-AwAA

Logs

No response

System Info

System:
    OS: Linux 6.5 Arch Linux
    CPU: (32) x64 13th Gen Intel(R) Core(TM) i9-13900HX
    Memory: 18.23 GB / 31.19 GB
    Container: Yes
    Shell: 5.2.15 - /bin/bash
  Binaries:
    Node: 20.9.0 - /usr/bin/node
    Yarn: 1.22.19 - /usr/bin/yarn
    npm: 10.2.1 - /usr/bin/npm
    pnpm: 8.10.0 - /usr/bin/pnpm
    bun: 1.0.4 - /usr/bin/bun
  Browsers:
    Chromium: 118.0.5993.117
    [Note: Seems this thing doesn't pick up Firefox. Running FF Dev 120.0b4 from AUR]
  npmPackages:
    svelte: ^5.0.0-next.2 => 5.0.0-next.2

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