We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
not working with React.forwardRef
The text was updated successfully, but these errors were encountered:
You can create an inner ref when the forwarded ref is null and coerce it to exclude callback refs.
null
import { ForwardedRef, RefObject, useRef } from 'react' function useEnsuredRef<T>(ref: ForwardedRef<T>): RefObject<T> { const defaultRef = useRef<T>(null) if (typeof ref === 'function') { throw new Error('callback refs are not supported') } return ref === null ? defaultRef : ref } export default useEnsuredRef
Sorry, something went wrong.
No branches or pull requests
not working with React.forwardRef
The text was updated successfully, but these errors were encountered: