-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
docs: address $effect
feedback
#15107
base: main
Are you sure you want to change the base?
Conversation
|
|
Do we need a section to say that effects don't run on the server, and also they don't run in places where you need an active effect already, like an event listener or module instance? |
These are good changes! I'm not too sure about the ordering change in the side bar but I don't mind either way.
Do you mean that they need an effect parent. That is already stated in the docs pretty far up. I also think we should add something along the line of @paoloricciuti's recent "state in a derived" example to the "when not to use effects" section |
imo to prevent the overuse of $effect the docs/Tutorial should have examples, that showcase common alternatives where people would use $effect otherwise. the docs should have best practice examples |
Should have a list of all the places where svelte has encouraged the use of
|
If an API is documented, it's generally assumed it's available for use. So the first line should include a warning explicitly stating that it should not be used, rather than beginning with a standard paragraph explaining its functionality. |
Is this an exhaustive list? If not, how would users understand where you need an active effect?
The term "parent effect" appears three times, but is never defined. Is a parent/child effects when you do something like
Yeah, that makes sense unless we end up adding
The
It is available for use. It's just important to use it as intended. The lightbulb callout has been moved up two paragraphs and now is right at the beginning, so I think it will be pretty prominent |
That is the use case for
I'm pretty sure "parent effect" refers to |
The effect root can be the parent bit so can other $effect and $effect.pres. In fact internally Svelte creates lots of different types of effect for things like if blocks and each blocks. These too can be parents. |
We've seen that
$effect
is being widely / wildly overused as Svelte 5 is adopted. This PR doesn't change the contents of the$effect
docs much, but hopefully makes it easier to notice and retain some key pieces of information.This makes a few changes:
$effect
down below$props
in the sidebar. This sidebar seems to be sorted by order of importance, so we can reorder to signal that$effect
should be used less than$props