Open fewkz opened 1 year ago
not sure about this, actually, refs being typed as any
is nice, because you can usually assume the value of a ref correctly, there's mostly not going to be a case where you really want to assert
whatever it's value is. Getting autocomplete for .current
is nice, but wow is it nit-picking.
An implementation of this is available in the https://github.com/fewkz/froact/tree/ref-binding branch
Make a
froact.createRef()
function that returns{ current: Instance }
with the code:As it turns out, you can do .current on Roact refs. We can type the
ref
property on Roblox instance components as{ current: Instance }
so that you'll never fuck up the type of refs ever!We get the beautiful, absolutely amazing extravagance of branch-based luau type inference! This is absolutely invaluable.
oh, and while we're add it, add
froact.useRef(hooks)
, instead of doinghooks.useMemo(froact.createRef(), {})