-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Revert "[feat] Suggest props destructuring if possible" #6099
Conversation
This reverts commit b1dafb8.
🦋 Changeset detectedLatest commit: 8a7483b The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
I'm not sure what the proper protocol around changesets is when reverting. Should the deleted changeset stay deleted, and should we add a new changeset? |
The old changeset stays (no deletion) and you add a new one. |
What about the alternative fix to add |
I'm not personally keen on it — we're literally saying that it's a suggestion for how to write the code, when it's very much not. I really think it's better to encourage people to complete the migration, otherwise codebases will be left in a half-migrated state. |
The migration guide also suggests destructuring
|
I think that's actually a good compromise — it points to the hacky solution without endorsing it. We should probably update the sample to include the initial |
(updated it) |
gonna go ahead and merge this so we're not suggesting buggy code to people, we can always discuss unreverting it with the |
Is this why I've been getting frequent undefined errors when I destructure the data prop in the +page.svelte file? For example, if I return { foo: { something: 'string' } } from +layout.server.ts and { bar: { something: 'string' } } from +page.server.ts, then I would use something like this to destructure:
This would work most of the time, but occasionally I would get undefined errors. As if the component was trying to render before the data had been destructured properly. If I just skip the destructring and call data.foo.something and data.bar.something inside the page component, is that the most reliable way to do it? |
Your given example should work, the html is rendered only after all reactive statements are evaluated |
Reverts #6069. Unfortunately this creates buggy code, because the destructured values aren't first assigned until after the
<script>
contents execute.People need to manually migrate this stuff. Offering a half measure with gotchas is worse than doing nothing IMHO.