Closed otonashixav closed 2 years ago
Hi, thanks for the issue. I made a commit to solve this and added your examples as test cases, but I'm going to see if I can address one or both of your other issues soon before publishing a new package. I'll let you know when the fixed version is published to npm.
This is fixed in v0.4.7
!
Describe the bug The following examples cause reactivity to warn with the message "This function should be passed to a tracked scope (like createEffect) or an event handler because it contains reactivity."
It is occasionally useful to place IIFEs in JSX if one does not wish to place the function into a variable for some reason. To be clear, while not executing the function is possible, it is undesired as they are compiled differently in certain situtations e.g. passing multiple children to a component or fragment),
(() => count())()
turns intomemo(() => count())
whereas() => count()
turns into() => count()
, and() => count()
is a function, whereas(() => count())()
is resolved to a getter when passed as the only child of a component.Expected behavior As the functions are immediately executed within a tracked scope there should be no warning.