Why always let props = $props()
instead of const
?
#15187
Answered
by
brunnerh
Fd929c2CE5fA
asked this question in
Q&A
-
https://svelte.dev/docs/svelte/$props I noticed that all the examples use |
Beta Was this translation helpful? Give feedback.
Answered by
brunnerh
Feb 2, 2025
Replies: 1 comment 2 replies
-
If you use So in scenarios where you destructure and have at least one property you want to change, you have to use <script>
let { value = $bindable(), ...rest } = $props();
</script>
<input bind:value {...rest} /> |
Beta Was this translation helpful? Give feedback.
2 replies
Answer selected by
Fd929c2CE5fA
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If you use
const
, you cannot reassign the variable, that is about it.So in scenarios where you destructure and have at least one property you want to change, you have to use
let
. E.g.