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
Using a simple component that maps onto an array, the transform does not see that the children are actually using signals and does not trigger the transform.
Example:
exportfunctionApp({ name }){constgreetings=["Hello","Goodbye"]constchildren=greetings.map((greeting)=><divkey={greeting}>{greeting}{name.value}</div>)return<div>{children}</div>;}
After digging into the babel plugin for a little while, it looks like the following happens when using a map:
We iterate over all MemberExpression
We find the signal access in Array.map
We attempt to set on the parent function scope that this function uses signals
We end up writing on the arrow function of the map instead of the component
We iterate over function calls, check if they both contain JSX and signals
Turns out the function is not marked as using signals since it was added to the map's arrow function scope.
Transform ignores our component.
A naive and not performant solution would be to recursively write to the parent until we hit the root of our program, which should hopefully be just a handful of levels deep.
There's probably a better way of solving this, I'd love some feedback from folks more familiar with babel plugins. 😄
Using a simple component that maps onto an array, the transform does not see that the children are actually using signals and does not trigger the transform.
Example:
I opened a draft PR adding a test showing the error case: https://github.com/preactjs/signals/pull/551/files#r1552520125
The text was updated successfully, but these errors were encountered: