Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

docs: $props destructuring is reactive #16901

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
hyunbinseo wants to merge 1 commit into sveltejs:main
base: main
Choose a base branch
Loading
from hyunbinseo:patch-2

Conversation

Copy link
Contributor

@hyunbinseo hyunbinseo commented Oct 6, 2025

Unlike $derived,

If you use destructuring with a $derived declaration, the resulting variables will all be reactive

the $props documentation does not specify that the destructured variables are reactive. This is all it says:

...though more commonly, you’ll destructure your props:

Before submitting the PR, please make sure you do the following

  • It's really useful if your PR references an issue where it is discussed ahead of time. In many cases, features are absent for a reason. For large changes, please create an RFC: https://github.com/sveltejs/rfcs
  • Prefix your PR title with feat:, fix:, chore:, or docs:.
  • This message body should clearly illustrate what problems it solves.
  • Ideally, include a test that fails without this PR but passes with it.
  • If this PR changes code within packages/svelte/src, add a changeset (npx changeset).

Tests and linting

  • Run the tests with pnpm test and lint the project with pnpm lint

Copy link

changeset-bot bot commented Oct 6, 2025

⚠️ No Changeset found

Latest commit: 8b42d42

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link

Copy link
Contributor

github-actions bot commented Oct 6, 2025

Playground

pnpm add https://pkg.pr.new/svelte@16901

Copy link
Member

Rich-Harris commented Oct 13, 2025
edited
Loading

Does this really need spelling out? This hasn't been a point of confusion, to my knowledge. If we add callouts for everything, people will develop a blindness to them

Copy link
Contributor Author

I still think it's magical and would be nice if it was specified in the docs.

Especially since $props is the only runes API that kind of requires destructuring (data, params, etc.)

Maybe adding the following section from $derived in both $state and $props could be the way to go:

If you use destructuring with a $derived declaration, the resulting variables will all be reactive — this...

I was reading through the docs, and reading that section was a aha moment for me that $props destructuring pretty much works the same way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /