#How can I execute a function from parent?
14 messages · Page 1 of 1 (latest)
ref is a special prop that compiles to ref={e => your_variable = e}. Other props don't get that treatment. Just use the function form
So to pass a ref from child (or any other prop) you do props.ref(your_value)
I meant to say that i wanna execute a function from parent, I wanna make my own ref kinda thing
ah 🤔
That seems to work, thanks 🙂
do you know how i could use it with typescript?
interface Props {
ref?: what goes here?
}
See solids types for reference
I saw Ref but that didnt seem to work properly
it's T | (v: T) => void or something
but you have to lie to typescript when using it, as it always compiles to a function so it cannot be T
ah
there is mergeRefs in solid-primitives that aims to help with refs a little bit. But it's not necessary. I'll just hide the type assertion as implementation detail
i see