foolswisdom
How are you supposed to satisfy refs when not forwarding to a pure DOM node?
I expect there's nothing built in. The types are often written with elements in mind, reusing them for components may not be feasible. In some cases it makes sense to adjust the existing types (make a PR), sometimes not
6 replies
How are you supposed to satisfy refs when not forwarding to a pure DOM node?
The ref prop received will be a function, even if the type passed to the ref prop is a variable (the compiler will simply create a function that takes a value and assigns to that variable). The Ref type allows for both, because it's defined in terms of the type that can be passed. If you don't like that, you should use a different type.
The reason the type includes undefined is because you explicitly added undefined to the type generic passed to Ref, so of course TS says it's possibly undefined
6 replies
createResource signal isn't trigger if undefined or null
Also in the docs https://docs.solidjs.com/reference/basic-reactivity/create-resource
fetchData will be called as soon as source has any value other than false, null, or undefined.Feels like it could be better surfaced if also described not as part of a snippet
3 replies