S
SolidJS4mo 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
Brendonovich4mo 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
gabriel4mo 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
Brendonovich4mo 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
gabriel4mo 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
More Posts
Does solid-element support defining methods on web components?I'm not currently using `solid-element` to define my web component, because I need to define methodsI'd like to see an example of working with a microservices API architectureI think this is the example that is missing from SolidstartSolidStart or Vite + solid-pwa plugin for creating a fast and secure PWA app?I want to create a PWA app using Solid. I am not decided on if I want to use CSR or SSR but I'm leanis Index of Store that is array Signal?I created an array containing several objects based on createStore. When I iterate through this arracaptureStoreUpdates vs reconcileHi! I'm trying to get a stream of immutable object values from a store. The store is frequently updErrors loading Bootstrap SASS in dev-modeI'm migrating a small app from Solid Start 0.3 to 0.5, so I started with a new app and am bringing tsome confusion regarding authentication when accessing third-party APIs in SolidStart.I have some confusion regarding authentication when accessing third-party APIs in SolidStart. Here’sUninitialized signal in JSX but initialized in componentI have a component that is using an xstate machine to handle some state. At the top of the componentunderstanding store setter updatesIn this example: ```typescript import { produce } from "solid-js/store" // without produce setStorremove element from store array createStore([])hi, i need to move element in store to the front of the array or delete it and add it to the front.