Skip to content
New issue

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

React-dom findDOMNode is being removed in React 19 #37408

Closed
Tracked by #37951
anomiex opened this issue May 15, 2024 · 0 comments · Fixed by #38339
Closed
Tracked by #37951

React-dom findDOMNode is being removed in React 19 #37408

anomiex opened this issue May 15, 2024 · 0 comments · Fixed by #38339
Assignees
Labels
[Focus] Compatibility Ensuring our products play well with third-parties [Platform] Atomic [Platform] Simple [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ [Pri] Normal [Type] Bug When a feature is broken and / or not performing as intended [Type] Janitorial

Comments

@anomiex
Copy link
Contributor

anomiex commented May 15, 2024

Impacted plugin

Jetpack

Quick summary

In React 19, the react-dom findDOMNode() function is being removed. More details on this are at https://react.dev/blog/2024/04/25/react-19-upgrade-guide#removed-reactdom-finddomnode

I've already cleaned up most of the uses of findDOMNode() in the monorepo in #37380, but I couldn't figure out how to replace the uses in projects/plugins/jetpack/_inc/client/components/popover/index.jsx.

// update context (target) reference into a property
if ( ! isDOMElement( nextProps.context ) ) {
this.domContext = ReactDom.findDOMNode( nextProps.context );
} else {
this.domContext = nextProps.context;
}

// store context (target) reference into a property
if ( ! isDOMElement( this.props.context ) ) {
this.domContext = ReactDom.findDOMNode( this.props.context );
} else {
this.domContext = this.props.context;
}

if ( this.props.ignoreContext && shouldClose ) {
const ignoreContext = ReactDom.findDOMNode( this.props.ignoreContext );
shouldClose =
shouldClose &&
ignoreContext &&
ignoreContext.contains &&
! ignoreContext.contains( event.target );
}

Since these are operating on an arbitrary React element passed in, we may need to change the interface for Popover to require an actual DOM node ref or something instead.

While this isn't a problem yet (React 19 is still in beta), eventually WordPress will start shipping it instead of React 18. At that point Popover will break, possibly breaking entire pages, so if we can clean this up ahead of time that would be useful.

Steps to reproduce

  1. git grep findDOMNode

A clear and concise description of what you expected to happen.

No results calling the react-dom function of that name.

What actually happened

projects/plugins/jetpack/_inc/client/components/popover/index.jsx:                      this.domContext = ReactDom.findDOMNode( nextProps.context );
projects/plugins/jetpack/_inc/client/components/popover/index.jsx:                      const ignoreContext = ReactDom.findDOMNode( this.props.ignoreContext );
projects/plugins/jetpack/_inc/client/components/popover/index.jsx:                      this.domContext = ReactDom.findDOMNode( this.props.context );

Impact

All

Available workarounds?

There is no user impact (yet)

Platform (Simple and/or Atomic)

Simple, Atomic, Self-hosted

Logs or notes

No response

@anomiex anomiex added [Type] Bug When a feature is broken and / or not performing as intended [Type] Janitorial [Focus] Compatibility Ensuring our products play well with third-parties Needs triage Ticket needs to be triaged [Pri] Normal and removed Needs triage Ticket needs to be triaged labels May 15, 2024
@github-actions github-actions bot added [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ [Platform] Atomic [Platform] Simple labels May 15, 2024
@coder-karen coder-karen self-assigned this Jul 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Focus] Compatibility Ensuring our products play well with third-parties [Platform] Atomic [Platform] Simple [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ [Pri] Normal [Type] Bug When a feature is broken and / or not performing as intended [Type] Janitorial
2 participants