mui-datatables
mui-datatables copied to clipboard
States are not updating in customBodyRender
const [catalogClass, setCatalogClass] = useState({});
customBodyRender: (_, tableMeta) => {
// updateValue("here");
const value = catalogClass[tableMeta.rowData[1]];
console.log("here", value, _, tableMeta);
return (
<>
<Select
labelId="=catalog-class-label"
id={catalog-class-select-${tableMeta.rowData[1]}}
// disabled={disabled}
value={value}
defaultValue={value}
onClick={e => {
e.stopPropagation();
e.preventDefault();
}}
onChange={e => handleChange(e, tableMeta)}
disableUnderline
MenuProps={{
anchorOrigin: {
vertical: "bottom",
horizontal: "left"
},
transformOrigin: {
vertical: "top",
horizontal: "left"
},
getContentAnchorEl: null,
MenuListProps: { disablePadding: true },
PaperProps: { square: true }
}}
>
{catalogClassesData &&
catalogClassesData.map(value => {
const formattedContenClass = formatToTitleCase(value);
return (
<MenuItem value={value} key={value}>
{formattedContenClass}
</MenuItem>
);
})}
</Select>
</>
);
}
The state inside catalogClass is {} even the state change outside