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
I have a list that can be filtered, displayed with an <Item/> component in an each block. The item component has only one props which has a default value.
The first rendering works well, the Item props takes the props or set the default value if the props is undefined. After filtering, the item of the list with a value "undefined" will not be displayed correctly with the default value of the <Item/> component.
I tried with and without a keyed each block. It does not change anything.
I'd exepect that the default value is set even after filtering.
There is workarounds: setting the default value when the value is used : {value || "default value"}
This is another manifestation of an issue that has come up a number of times before, notably in #4442, with documentation clarified in #4460. There's no concept of "reset this component to the original default value of this prop", just to have a default initial value. In an {#each} block, you're effectively trying to update certain props of certain components to undefined, which is what you're seeing happen here.
Describe the bug
I have a list that can be filtered, displayed with an
<Item/>
component in aneach block
. The item component has only one props which has a default value.The first rendering works well, the Item props takes the props or set the default value if the props is undefined. After filtering, the item of the list with a value "undefined" will not be displayed correctly with the default value of the
<Item/>
component.I tried with and without a keyed each block. It does not change anything.
I'd exepect that the default value is set even after filtering.
There is workarounds: setting the default value when the value is used :
{value || "default value"}
Reproduction
Here is a REPL: https://svelte.dev/repl/4944b2037a034b7fb50806e801f080cf?version=3.53.1
Logs
No response
System Info
Severity
annoyance
The text was updated successfully, but these errors were encountered: