Dashboard sipadu mbip
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

useSafeState.js 318B

123456789101112
  1. import { useCallback } from 'react';
  2. import useMounted from './useMounted';
  3. function useSafeState(state) {
  4. var isMounted = useMounted();
  5. return [state[0], useCallback(function (nextState) {
  6. if (!isMounted()) return;
  7. return state[1](nextState);
  8. }, [isMounted, state[1]])];
  9. }
  10. export default useSafeState;