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

Bug: function reactFormatter uses ReactDOM.render #280

Open
Tabulanga opened this issue Mar 1, 2023 · 6 comments
Open

Bug: function reactFormatter uses ReactDOM.render #280

Tabulanga opened this issue Mar 1, 2023 · 6 comments

Comments

@Tabulanga
Copy link

I am using React-tabulator along with Next.js.
When I need to use function reactFormatter, I get an error:

next-dev.js?3515:20 Warning: ReactDOM.render is no longer supported in React 18. Use createRoot instead. Until you switch to the new API, your app will behave as if it's running React 17. Learn more: https://reactjs.org/link/switch-to-createroot

import { ColumnDefinition, reactFormatter, ReactTabulator } from 'react-tabulator';

const columns: ColumnDefinition[] = [
  {
    title: 'Power',
    field: 'powerState',
    formatter: reactFormatter(<PowerIcon />),
  },
];

"next": "13.2.1",
"react": "18.2.0",
"react-tabulator": "0.18.1"

@rabbit-roger
Copy link

I have the same error with React 18.

@Tabulanga
Copy link
Author

@ngduc is this repository abandoned?

@martin083
Copy link

I am also seeing this….any timeline on a fix? App reverts back react 17 because of this :)

@aleruizj
Copy link

aleruizj commented Dec 8, 2023

This function serves as a workaround for the "ReactDOM.render is no longer supported in React 18" warning. By using createRoot from react-dom/client, it adheres to the new API standard introduced in React 18. Here's the updated reactFormatter function that uses createRoot for rendering components within Tabulator:

I create a PR for this fix

#287

import { createRoot } from 'react-dom/client';

function reactFormatter(JSX) {
  return function customFormatter(cell, formatterParams, onRendered) {
    onRendered(() => {
      const cellElement = cell.getElement();
      if (cellElement) {
        cellElement.innerHTML = '';
        const root = createRoot(cellElement);
        root.render(JSX);
      }
    });
    return '<div></div>';
  };
}

@jojulio
Copy link

jojulio commented Apr 9, 2024

any alternative to deal with this?

@Tabulanga
Copy link
Author

abandoned this wrapper and use tabulator-tables directly

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants