强制组件更新 useForceUpdate
一个hook,完成组件的强制更新
import type { DispatchWithoutAction } from 'react';
import { useReducer } from 'react';
const useForceUpdate = () => {
const [, dispatch] = useReducer((x) => x + 1, 0);
return dispatch as DispatchWithoutAction;
};