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
{{ message }}
Repository navigation
Show with a callback with no params is getting re-computed #869
I think this is related to components wrapped in a thunk within fragments rather than Show. Show passes through props.children when it is a function with no parameters, allowing the bug to take effect. If you replace the fragment with a div in the example given, the issue disappears. If you remove the Show component completely, leaving just {() => <Inner />}, the issue persists.
Hmm. Yeah that's tricky.. mostly that Show doesn't treat the callback without arguments as a callback but instead as passing an accessor as a child. There just isn't a good way to differentiate. In which case it is just passing the function through which isn't memoized or an actual signal itself. This means that in the fragment context it is re-running without guards.. which happens because it's nested as the Show is memoized but the value it returns is just a function that isn't, and in theory this could be true to n-depth.
The handling is imperfect but also I'd argue this usage is incorrect since your intention isn't to return a non-memoized child and rather have it work like a callback form. Technically the correct solve is to run the children helper perhaps but this may have other implications. Hmm... the conceptual problem is that callback without argument behaves differently. In a sense that the helper is too overloaded. It's possible control flow should be returning children(() =>) instead of createMemo(() =>). That is interesting.
In anycase this is a longer term consideration. I doubt we change anything here immediately but it is worth considering for future big changes.
Yeah given this issue will just go stale here. I am going to close it as we aren't going to be taking any action in the near future as this pattern basically is a concession by design and easy to point to as improper use as there shouldn't be an expectation of it working as indicated. This takes more than just wrapping the value sufficiently as the API basically doesn't lend to it.
Activity
otonashixav commentedon Feb 28, 2022
I think this is related to components wrapped in a thunk within fragments rather than
Show.Showpasses throughprops.childrenwhen it is a function with no parameters, allowing the bug to take effect. If you replace the fragment with a div in the example given, the issue disappears. If you remove the Show component completely, leaving just{() => <Inner />}, the issue persists.Minimal reproduction showing this: https://playground.solidjs.com/?hash=-12796868&version=1.3.7
mdynnl commentedon Feb 28, 2022
Aha fixed it https://playground.solidjs.com/?hash=1513808350&version=1.3.7
mdynnl commentedon Feb 28, 2022
I'll just put this here also, cause this is related but falls under feature request. https://playground.solidjs.com/?hash=101101936&version=1.3.7
ryansolid commentedon Feb 28, 2022
Hmm. Yeah that's tricky.. mostly that Show doesn't treat the callback without arguments as a callback but instead as passing an accessor as a child. There just isn't a good way to differentiate. In which case it is just passing the function through which isn't memoized or an actual signal itself. This means that in the fragment context it is re-running without guards.. which happens because it's nested as the Show is memoized but the value it returns is just a function that isn't, and in theory this could be true to n-depth.
The handling is imperfect but also I'd argue this usage is incorrect since your intention isn't to return a non-memoized child and rather have it work like a callback form. Technically the correct solve is to run the
childrenhelper perhaps but this may have other implications. Hmm... the conceptual problem is that callback without argument behaves differently. In a sense that the helper is too overloaded. It's possible control flow should be returningchildren(() =>)instead ofcreateMemo(() =>). That is interesting.In anycase this is a longer term consideration. I doubt we change anything here immediately but it is worth considering for future big changes.
ryansolid commentedon Mar 30, 2022
Yeah given this issue will just go stale here. I am going to close it as we aren't going to be taking any action in the near future as this pattern basically is a concession by design and easy to point to as improper use as there shouldn't be an expectation of it working as indicated. This takes more than just wrapping the value sufficiently as the API basically doesn't lend to it.