ref.current access lint rule broken by Typescript as
type assertion
#19
Unanswered
yepitschunked
asked this question in
General Questions
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
We have some code which uses the
useEvent
RFC: https://github.com/reactjs/rfcs/blob/useevent/text/0000-useevent.md#internal-implementationThe original code (not exactly what we use, but close enough) passes the lint checks:
However, we've converted the code to TypeScript, and the returned useCallback has a type assertion:
This breaks the lint rule, giving a
Ref values (the
currentproperty) may not be accessed during render. (https://react.dev/reference/react/useRef)
error.Beta Was this translation helpful? Give feedback.
All reactions