You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I got an error that is ONE HUNDRED PERCENT my fault, but it happens because of this part of Solid's update algorithm.
The following (nasty) code approximately reproduces my error (Also available in this playground)
import{typeAccessor,batch,createMemo,createRoot,createSignal,}from"solid-js";functionpreventCircular<T>(f: Accessor<T>): Accessor<T>{varrunning=false;return()=>{if(running)thrownewError("A memo called itself");running=true;try{returnf();}finally{running=false;}};}createRoot((_)=>{const[a,s]=createSignal(0);constb=createMemo(a);varc: Accessor<number>|undefined;constd=createMemo(()=>{// This memo needs to be nested for the error to come upc??=createRoot((_)=>preventCircular(createMemo(b)));returnc()+1;});// The batch is needed because we need to update the inner memo ("c") first, which will then cause the update of its parent ("d"), but only if the update goes through the change of a memo ("b"), the change of a signal ("a") is not enoughbatch(()=>{s(4);c!();});});
To fix my error, I think it would be very helpful to understand why it's needed to update the ancestors, does anyone here knows the reason?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I got an error that is ONE HUNDRED PERCENT my fault, but it happens because of this part of Solid's update algorithm.
The following (nasty) code approximately reproduces my error (Also available in this playground)
To fix my error, I think it would be very helpful to understand why it's needed to update the ancestors, does anyone here knows the reason?
Beta Was this translation helpful? Give feedback.
All reactions