You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This comes down to stylistic preference. I personally for example want to use const for components that only have readonly props. Or I prefer to use const for $derived because for me it better communicates that this is a readonly value, not necessarily that the value itself never changes.
We shouldn't be in the business of dictating these preferences, therefore closing.
<script lang="ts">
let { options, selected = $bindable() }: { options: string[], selected: number } = $props();
</script>
In this scenario, I’d like to define both const options and let selected simultaneously, but I can’t invoke $props twice. I suppose there’s currently no solution for this?
The text was updated successfully, but these errors were encountered:
AsaMitakaIT
changed the title
The contradiction between const and $bindable
Conflict between const and $bindable
Apr 13, 2025
For a lot of props you could do <script lang="ts"> let { selected = $bindable(), …_readonlyProps }: { prop1: string, prop2:number, selected: number } = $props(); const { prop1, prop2, …restProps} = $derived(_readonlyProps); </script>
Originally posted by @dummdidumm in #12121
In this scenario, I’d like to define both const options and let selected simultaneously, but I can’t invoke $props twice. I suppose there’s currently no solution for this?
The text was updated successfully, but these errors were encountered: