S
SolidJS10mo ago
gabriel

How does the "You might not need an effect" page from react.dev translate to SolidJS's effects?

I feel like they are both the same construct, but since Solid has a fundamentally different way of rendering and constructing components it feels to me like a few things should differ. I was reading through it and thinking about this as I wanted to improve my own SolidJS code. One of the things I am already sure it differs on is for the section of "Resetting all state when a prop changes": https://react.dev/learn/you-might-not-need-an-effect#resetting-all-state-when-a-prop-changes. But as I mentioned, I'm not exactly sure how this section would look like on a SolidJS docs as we don't have one page for this, at least AFAIK. I first wanted to ask a question about this specific section of this react.dev page but I think it might be more interesting to actually discuss the whole page as there may be many things from this page that both might not apply as well might not be the optimal solution inside of SolidJS.
You Might Not Need an Effect – React
The library for web and native user interfaces
4 Replies
Brendonovich
Brendonovich10mo ago
the equivalent to that is using a keyed <Show> i'm always recommending that page of the react docs to my team, but tbh with how performant solid is it's decently less necessary, though getting into the habit of deriving w/ memos instead of synchronising w/ effects is very useful
gabriel
gabrielOP10mo ago
yeah, I think basically all worries of performance React brings on that page are about re-rendering, but the bugs that effects can cause are still relevant for Solid
Brendonovich
Brendonovich10mo ago
oh for sure, especially if you're trying to take advantage of suspense + transitions properly, gotta have your data flowing correctly at least all the data fetching examples can just be replaced by createResource
gabriel
gabrielOP10mo ago
yeah LOL I wonder if Solid should have a docs page on this as well because It is always time consuming understanding these concepts on Solid through the React docs
the equivalent to that is using a keyed <Show>
Nice, thanks
Want results from more Discord servers?
Add your server