S
SolidJS13mo ago
Evert

How can this incredibly simple piece of code lead to "Maximum call stack size exceeded" ?

The entire code for this demo is here: https://playground.solidjs.com/anonymous/7ec72a47-1bb4-4e9f-bf1d-3103d3d2c2d0 I just adapted it from one of the tutorial pages. The culprit is one line, as far as I can tell: createEffect(() => [0, 359].includes(num()) && setDir(dir() * -1)); I just don't understand how that one line creates a stack overflow. Can anybody enlighten me and maybe offer an alternative? Any help would be much appreciates. 🙏
Solid Playground
Quickly discover what the solid compiler will generate from your JSX template
7 Replies
REEEEE
REEEEE13mo ago
You're reading and writing to dir, so everytime it gets set the effect reruns causing a loop just add untrack
[0, 359].includes(num()) && setDir(untrack(dir) * -1)
[0, 359].includes(num()) && setDir(untrack(dir) * -1)
Evert
Evert13mo ago
Ah, thanks! Yep, that did the job, thanks a lot @._rb Now how do I close this thread? 🤔
REEEEE
REEEEE13mo ago
not too sure, just add a check reaction to the post. should be enough
Evert
Evert13mo ago
!close
Evert
Evert13mo ago
@._rb sorry to bother you again, but since we're here. Do you also get this typescript error when you open my playground link? It doesn't make sense? Does it? Like, as far as I'm aware, all elements that can contain text have a color style attribute available to use, right?
Evert
Evert13mo ago
And I mean, it even works in the result pane. So TypeScript is just plain wrong here it seems.
REEEEE
REEEEE13mo ago
might just be an issue with the tsconfig of the playground I guess The usage is correct Actually, I think it is an issue with the playground because I sort of remember issues with the style property coming up previously
Want results from more Discord servers?
Add your server
More Posts
How to protect all routes other than sign-inHi there, I am making an app where I only want signed-in users to see the content, I want all routesTypeError: Cannot read properties of undefined (reading 'remove') at reconcileArraysI get this during a `refetch()` call of a resource. Pretty hard to debug and see what actually getsValidating a field based on promise values min and max with yup and react form handlerconst schemaReference = (res) => { console.log(res); return yup.object({ unit: yup.strReaching into nested properties and keeping them reactive?Coming from React I really like that I can destruct nested props into single variables, in this examTesting difficulties in solid-startI'm running into some perplexing errors with Vitest in my SSR-enabled Solid Start app. In the importReactSVG like component in SolidHey, I recently was remaking my portfolio website in astro with some solid.js. I wanted to make an iSuspense not updating when navigating to Route directlyHey folks, I am currently having a weird issue I can't quite solve: We have a route which receivesHow do you do logging errors etc. In solid start?Like how do you get logs you can browse for instance in a web interface when solid start app is runnwarnings when passing onClick as propI get a warning in the child component when I pass an event handler from the parent. In the parenRoutes are being duplicated when HMR is onIt seems whenever the file updates the route is not actually refreshed and it just adds the updated