Skip to content

Getting "Accessing element.ref was removed in React 19" error #2846

Closed Answered by tammyhart
tammyhart asked this question in Q&A
Discussion options

You must be logged in to vote

After some digging, I discovered the culprit is a library I failed to include in my sample code: focus-trap-react

I didn't dig deep enough to figure out why it was causing weirdness with ref, but I did find a solution which is not that pretty, but removes the error.

My JSX before:

<FocusTrap>
  <Container ref={ref}>
    {children}
  </Container>
</FocusTrap>

After:

<Container ref={ref}>
  <FocusTrap>
    <div>{children}</div>
  </FocusTrap>
</Container>

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by tammyhart
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant