gregnb / gregnb/mui-datatables

Error with filterType: 'checkbox'

Open
#1,952 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
2.7k
Forks
906
PR merge metrics
No merged PRs in 30d

Description

When using _filterType: 'checkbox'_ and one post in the data is missing the field that should be filtered on, an uncaught exception will crash the application.

## Expected Behavior
Missing data property, or value (should also apply to when using _enableNestedDataAccess_) should generate a checkbox without a label (or no checkbox at all).

## Current Behavior
An uncaught exception will crash the application.

Warning: Failed prop type: The prop `label` is marked as required in `ForwardRef(FormControlLabel)`, but its value is `null`.
FormControlLabel.js:138 Uncaught TypeError: Cannot read properties of null (reading 'type')

## Steps to Reproduce (for bugs)
Example:
```
import React from "react";
import MUIDataTable from "mui-datatables";

class Example extends React.Component {

state = {
counter: 0,
data: [
{ name: "Gabby George"},
{ name: null }
]
}

rerender = () => {
this.setState((prevState, props) => ({
counter: prevState.counter + 1
}));
}

render() {

const columns = [
{
name: "name",
label: "Name",
}
];

const options = {
filter: true,
filterType: 'checkbox',
responsive: 'vertical'
};

return (

Re-render - {this.state.counter}


);

}
}

export default Example;
```

## Your Environment

| Tech | Version |
|--------------|---------|
| Material-UI | @mui/material@5.5.2 |
| MUI-datatables | "mui-datatables": "4.1.2" |
| React | "react": "17.0.2" |
| browser | Microsoft Edge 104.0.1293.70 (Official build) (64-bit) |

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.