'Warning: `value` prop on `input` should not be null. Consider using an empty string to clear the component or `undefined` for uncontrolled components
React keeps giving me this "Warning" (which registers as an error in the console) whenever I click on the edit row section of the material table. I understand the Warning is happening because there are some parameters of the table that are left undefined and therefore being logged as null. I am wondering how can I avoid this situation please see the code below. My components are uncontrolled as the user can type in the columns of a particular row of material table.
data={props.devices}
editable={{
onRowUpdate: (newData, oldData) =>
new Promise((resolve, reject) => {
setTimeout(() => {
const index = oldData.tableData.id;
let newArr = [...props.devices];
newArr[index] = newData;
setParts(newArr);
updatePart(newData, newData.device);
resolve();
}, 1000);
}),
Here is the full error:
index.js:1 Warning: `value` prop on `input` should not be null. Consider using an empty string to clear the component or `undefined` for uncontrolled components.
in input (created by ForwardRef(InputBase))
in div (created by ForwardRef(InputBase))
in ForwardRef(InputBase) (created by WithStyles(ForwardRef(InputBase)))
in WithStyles(ForwardRef(InputBase)) (created by ForwardRef(Input))
in ForwardRef(Input) (created by WithStyles(ForwardRef(Input)))
in WithStyles(ForwardRef(Input)) (created by ForwardRef(TextField))
in div (created by ForwardRef(FormControl))
in ForwardRef(FormControl) (created by WithStyles(ForwardRef(FormControl)))
in WithStyles(ForwardRef(FormControl)) (created by ForwardRef(TextField))
in ForwardRef(TextField) (created by WithStyles(ForwardRef(TextField)))
in WithStyles(ForwardRef(TextField)) (created by MTableEditField)
in MTableEditField (created by MTableEditRow)
in td (created by ForwardRef(TableCell))
in ForwardRef(TableCell) (created by WithStyles(ForwardRef(TableCell)))
in WithStyles(ForwardRef(TableCell)) (created by MTableEditRow)
in tr (created by ForwardRef(TableRow))
in ForwardRef(TableRow) (created by WithStyles(ForwardRef(TableRow)))
in WithStyles(ForwardRef(TableRow)) (created by MTableEditRow)
in MTableEditRow (created by MTableBody)
in tbody (created by ForwardRef(TableBody))
in ForwardRef(TableBody) (created by WithStyles(ForwardRef(TableBody)))
in WithStyles(ForwardRef(TableBody)) (created by MTableBody)
in MTableBody (created by Droppable)
in table (created by ForwardRef(Table))
in ForwardRef(Table) (created by WithStyles(ForwardRef(Table)))
in WithStyles(ForwardRef(Table)) (created by Droppable)
in div (created by Droppable)
in div (created by Droppable)
in div (created by Droppable)
in Droppable (created by ConnectFunction)
in ConnectFunction
in ConnectFunction (created by MaterialTable)
in div
in Unknown (created by WithStyles(Component))
in WithStyles(Component) (created by MaterialTable)
in div (created by ForwardRef(Paper))
in ForwardRef(Paper) (created by WithStyles(ForwardRef(Paper)))
in WithStyles(ForwardRef(Paper)) (created by Container)
in Container (created by MaterialTable)
in Provider (created by App)
in App (created by ErrorBoundary)
in ErrorBoundary (created by DragDropContext)
in DragDropContext (created by MaterialTable)
in MaterialTable
in Unknown (created by WithStyles(Component))
Solution 1:[1]
why are you using setTimeOut? the mui table receives null at first render, so just remove setTimeOut. and make sure no value is null, if its null replace it with empty string "".
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Mohammad Jihad |