mui-datatables icon indicating copy to clipboard operation
mui-datatables copied to clipboard

"React does not recognize the `isEmpty` prop on a DOM element" error in console with version 3.8.5

Open willykurmann opened this issue 2 years ago • 13 comments

"React does not recognize the isEmpty prop on a DOM element" error in console with version 3.8.5

Expected Behavior

When landing on a page containing a mui-datatable component, there should be no error in the console.

Current Behavior

When landing on a page containing a mui-datatable component, the following error is visible: image

Steps to Reproduce (for bugs)

  1. Use a MuiDatable and MUIDataTableColumn components

Your Environment

Tech Version
Material-UI 4.12.3
MUI-datatables 3.8.5
@types/mui-datatables 3.7.8
React 17.0.2
browser latest versions of chrome, firefox and edge
NX development

Update

After I built the app for production, the error isn't visible in the console. Might be something related to a development setting ?

willykurmann avatar Mar 17 '22 10:03 willykurmann

BTW is MuiDatable a typo ?

image

willykurmann avatar Mar 17 '22 10:03 willykurmann

This is happening to me too, but I haven't tried in production yet.

pintosack avatar Mar 21 '22 20:03 pintosack

This is happenning to me too. Most certainly the error not showing in production is due to webpack and babel hiding that from the user.

julianinsua avatar Mar 24 '22 14:03 julianinsua

Same for me

molotow11 avatar Mar 28 '22 12:03 molotow11

Same here. I've recently added the library so it's on the most up to date version and using updated versions of React as well

zulmycortez avatar Mar 28 '22 20:03 zulmycortez

after changing mui datatable version warning gone "mui-datatables": "^4.1.2",

prabhatb111 avatar Apr 05 '22 09:04 prabhatb111

If you, like me, cannot update to a version that fixes the issue here is a quick and dirty fix.

import { TableCell } from '@material-ui/core'

const oldRender = TableCell.render

TableCell.render = function (...args) {
    const [props, ...otherArgs] = args
    if (typeof props === 'object' && props && 'isEmpty' in props) {
        const { isEmpty, ...propsWithoutEmpty } = props
        return oldRender.apply(this, [propsWithoutEmpty, ...otherArgs])
    } else {
        return oldRender.apply(this, args)
    }
}

filipomar avatar Apr 05 '22 15:04 filipomar

If you, like me, cannot update to a version that fixes the issue here is a quick and dirty fix.

import { TableCell } from '@material-ui/core'

const oldRender = TableCell.render

TableCell.render = function (...args) {
    const [props, ...otherArgs] = args
    if (typeof props === 'object' && props && 'isEmpty' in props) {
        const { isEmpty, ...propsWithoutEmpty } = props
        return oldRender.apply(this, [propsWithoutEmpty, ...otherArgs])
    } else {
        return oldRender.apply(this, args)
    }
}

Where to add this code?

Bhuvanesh-git331 avatar Apr 06 '22 14:04 Bhuvanesh-git331

Can confirm that this is fixed in version 4.1.2. (we also upgraded React to v18)

pintosack avatar Apr 12 '22 17:04 pintosack

Where to add this code?

Anywhere before the rendering of the element, and it needs to be executed only once.

filipomar avatar Apr 15 '22 16:04 filipomar

I have the same error using mui-datatables": "^3.8.5" and "react": "^18.1.0". I updated mui-datatables to 4.2 but the table breaks in responsive mode. In version 3.8.5 when screen was small, each row was transformed into a columns, but with the latest version does not work anymore.

lazarogandolfo avatar Jun 23 '22 12:06 lazarogandolfo

Why don't you release the commit fixing this issue?

https://github.com/gregnb/mui-datatables/commit/af67b15c4e4b0621b23d3303276c1e5e54a14bf4

kasanoppa avatar Aug 29 '22 21:08 kasanoppa

Another Workaround which doesn't affect the code of the app: With PNPM you can "path" problematic dependency using pnpm patch https://pnpm.io/cli/patch

So, what I did

  1. cloned mui-datatables repo
  2. switched to v 3.8.5
  3. cherry-picked fix commit af67b15 (#1926)
  4. built project with npm run build
  5. copied output from dist
  6. Applied that output into pnpm patch folder
  7. executed pnpm patch-commit
  8. Committed patch to repo

benefits: I don't pollute my source code with hacks. Once I upgrade to newer version of mui-datatables - I can easily remove path file

kopach avatar Nov 24 '22 14:11 kopach