-
-
Notifications
You must be signed in to change notification settings - Fork 57
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
Usability problem of an array of superforms #396
Comments
It didn't occur to me to extract the form into a separate component 🤦 {#each superforms as superform}
<Comp {superform} />
{/each} Closing. |
I'm reopening this issue because I encountered a problem When I write this code <script>
const superforms = data.my_forms.map((form) =>
superForm(form, {
dataType: 'json'
})
);
</script>
{#each superforms as superform (superform.formId)}
<ConditionItem {superform} />
{/each} It works well but when a new form is added, then that's where I run into a problem If I try to use $derived const superforms = $derived(
data.condition_forms.map((form) =>
superForm(form, {
dataType: 'json'
})
)
); I get this error Uncaught Error: onDestroy can only be used during component initialisation. Repro https://www.sveltelab.dev/9tdm9ul193m3tz5
|
I found a way to fix it, I pushed my code here If you'd like, I can make a PR for this Cheers |
A PR for this would be very nice! |
Okay, I will send a PR for this |
The problem is bigger than I anticipated, it'll require an overhaul of the onDestroy/cleanup handling. It'll have to wait until later. For now, using calls to |
Okay, it will be good to have dynamic forms in the future. I will try to find a workaround for now. |
Description
I tried retuning multiple superforms in an array, but I could not use it in the frontend.
The only convenient way was to destructure each superform in the each tag but svelte doesn't support "declaring" stores out of the top-level of the component
If applicable, a MRE
https://www.sveltelab.dev/9tdm9ul193m3tz5
The text was updated successfully, but these errors were encountered: