Server pagination, I understand the logic but can't figure out how does the grid know the value of prevRowCountState
. Is it a undocumented thing, prefix a const/property with prev
then the grid knows it's for the previous value?
const [rowCountState, setRowCountState] = React.useState(rowCount);
React.useEffect(() => {
setRowCountState((prevRowCountState) =>
rowCount !== undefined ? rowCount : prevRowCountState,
);
}, [rowCount, setRowCountState]);
<DataGrid rowCount={rowCountState} />;
set<Something>
is action of setState
method for Something
. When supplying an argument in a form of function such as set<Something>((whatever)=> {...});
, whatever is the previous state of something.
References: