Replies: 2 comments 1 reply
-
I've been thinking it after writing said code. |
Beta Was this translation helpful? Give feedback.
1 reply
-
Perhaps an alternative to a new hook would be to simplify the API of const [element, setElement] = useSafeState<T | null>(null);
const elementRef = useHookableRef<T | null>(element, setElement); I believe this requires removing the requirement for the hookable ref's setter to return a value. Is there a use case for wanting to set a custom internal ref value that couldn't be achieved with a separate |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
This combination of
useSafeState
anduseHookableRef
looks very similar (but a lot cleaner) to something I had to do in my own code. If I understand correctly, it re-renders when a ref's value changes, right? This is indeed very convenient when trying to get a ref of an element that isn't rendered right away on mount, as mentioned in #755. May I suggest making a new hook for this?Beta Was this translation helpful? Give feedback.
All reactions