mui-data-grid 中的 prevRowCountState 是什么?
What is a prevRowCountState in mui-data-grid?
Server pagination,我懂逻辑但是想不通grid是怎么知道prevRowCountState
的值的。它是一个未记录的东西,在 const/property 前加上 prev
然后网格知道它是以前的值?
const [rowCountState, setRowCountState] = React.useState(rowCount);
React.useEffect(() => {
setRowCountState((prevRowCountState) =>
rowCount !== undefined ? rowCount : prevRowCountState,
);
}, [rowCount, setRowCountState]);
<DataGrid rowCount={rowCountState} />;
set<Something>
是 setState
方法对 Something
的操作。当以 set<Something>((whatever)=> {...});
等函数形式提供参数时,whatever 是 something.
的先前状态
参考文献:
- React's State,开始“要修复它,请使用第二种形式的 setState()...”
- Geek to Geek, example 4,
Server pagination,我懂逻辑但是想不通grid是怎么知道prevRowCountState
的值的。它是一个未记录的东西,在 const/property 前加上 prev
然后网格知道它是以前的值?
const [rowCountState, setRowCountState] = React.useState(rowCount);
React.useEffect(() => {
setRowCountState((prevRowCountState) =>
rowCount !== undefined ? rowCount : prevRowCountState,
);
}, [rowCount, setRowCountState]);
<DataGrid rowCount={rowCountState} />;
set<Something>
是 setState
方法对 Something
的操作。当以 set<Something>((whatever)=> {...});
等函数形式提供参数时,whatever 是 something.
参考文献:
- React's State,开始“要修复它,请使用第二种形式的 setState()...”
- Geek to Geek, example 4,