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

ReorderCell not working in React 19 due to ReactDOM.render no longer existing #743

Open
jimmycallin opened this issue Feb 15, 2025 · 5 comments
Assignees
Labels
bug dependencies Pull requests that update a dependency file help wanted
Milestone

Comments

@jimmycallin
Copy link

jimmycallin commented Feb 15, 2025

Expected Behavior

fixed-data-table-2 reordering feature should work in React 19

Current Behavior

When upgrading to React 19, you get an error when trying to reorder a cell that ReactDom.render is not a function.

Possible Solution

See here:

Replace ReactDOM.render with ReactDOM.createRoot for newer React versions.

Steps to Reproduce (for bugs)

Your Environment

  • Version used:
  • Browser Name and version:
  • Operating System and version (desktop or mobile):
  • Link to your project:
@pradeepnschrodinger pradeepnschrodinger self-assigned this Feb 17, 2025
@jimmycallin jimmycallin changed the title ReorderCell not working in React 19 due to ReactDom.render no longer existing ReorderCell not working in React 19 due to ReactDOM.render no longer existing Feb 17, 2025
@pradeepnschrodinger
Copy link
Collaborator

Thanks for filing.

This turned out be trickier than I imagined 😔 .
We have React v17 as a peer dependency version.

"peerDependencies": {
"react": ">=17.0.1",
"react-dom": ">=17.0.1"
},

To retain backward compatibility, I wanted to do feature detection by checking if ReactDOM.render or ReactDOM.createRoot exists at runtime.
Unfortunately, the newer v18/v19 API ReactDOM.createRoot is only present in the new react-dom/client package, which is not present in v17.

This means I can't do something like:

import ReactDOM from 'react-dom' // for react v17
// the next line throws an error for clients using react v17
import ReactDOMClient from 'react-dom/client' // for react v19

// ...

function renderDragProxy() {
  // ...

  // switch APIs based on what's available
  if (ReactDOMClient?.createRoot) {
    ReactDOMClient.createRoot(...).render(...)
  } else {
    ReactDOMClient.render(...)
  }
}

The path forward that I see is to make a new major version for FDT (v3.x) that drops support for React v17 in favor of React v18/v19.
But I'm gonna keep this open for a while to see if anyone has suggestions/workarounds.

cc: @juzerzarif @mycrobe @novakps @tchoiSchrodinger @miskreant

@jimmycallin
Copy link
Author

I think unfortunately that you are correct. While awaiting feedback, would you mind creating a beta of a next major version to unblock us upgrading to React 19? Thanks!

@pradeepnschrodinger
Copy link
Collaborator

Sure. Let me see if I can put a quick FDT v3-experimental release with React bumped up to test out stuff.

Btw, clients can also pass their own implementation for reordering cells.
ReorderCell is just designed as an HoC.

The simplest approach (just for unblocking purposes) would be to copy it's code, replace ReactDOM.render with ReactDOM.createRoot, and pass that as your header renderer.

@pradeepnschrodinger
Copy link
Collaborator

@jimmycallin , please try out v3.0.1-react-v19 and let me know how it works out.

Reordering worked out when I smoke tested locally.

@pradeepnschrodinger pradeepnschrodinger added the dependencies Pull requests that update a dependency file label Feb 20, 2025
@pradeepnschrodinger pradeepnschrodinger modified the milestones: v2.0, v3.0 Feb 20, 2025
@jimmycallin
Copy link
Author

just tried it out and so far so good - thank you! 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug dependencies Pull requests that update a dependency file help wanted
Projects
None yet
Development

No branches or pull requests

2 participants