I am using the react useState, now I want to do something when the setState complete. I am trying using useStateCallback to do this, this is the useStateCallback define:
const [currentRow, setCurrentRow] = useStateCallback<API.InterviewListItem>();
currentRow is the table row record, now I want to do something when when set current row complete, in my code, I do it like this:
<a
key="config"
onClick={() => {
setCurrentRow(record,(s:any) => {
// do something when the set current row complete
});
handleUpdateModalVisible(true);
}}
>
but when I compile the code, shows error like this:
Error: Function not implemented.
useStateCallback
.ant-design-pro/src/pages/apps/jobs/Interview/index.tsx:402
399 |
400 | export default TableList;
401 | function useStateCallback<T>(): [any, any] {
> 402 | throw new Error('Function not implemented.');
403 | }
404 |
405 |
View compiled
TableList
.ant-design-pro/src/pages/apps/jobs/Interview/index.tsx:101
98 | const [showDetail, setShowDetail] = useState<boolean>(false);
99 |
100 | const actionRef = useRef<ActionType>();
> 101 | const [currentRow, setCurrentRow] = useStateCallback<API.InterviewListItem>();
| ^ 102 | const [selectedRowsState, setSelectedRows] = useState<API.InterviewListItem[]>([]);
103 | const { initialState } = useModel('@@initialState');
104 |
View compiled
▶ 22 stack frames were collapsed.
This screen is visible only in development. It will not appear if the app crashes in production.
Open your browser’s developer console to further inspect this error. Click the 'X' or hit ESC to dismiss this message.
what was happen? what should I do to fix it? I have read this answer and followed by this: How to use callback with useState hook in react