/* eslint-disable react-hooks/exhaustive-deps */
import { useCallback, useEffect, useState } from "react";

/**
 * 挂载
 */
export const useMount = (func: () => void) => {
  useEffect(() => {
    func();
  }, []);
};

/**
 * 卸载
 */
export const useUnmount = (func: () => void) => {
  useEffect(
    () => () => {
      func();
    },
    []
  );
};

/**
 * forceUpdate
 */
export const useUpdate = () => {
  const [, setState] = useState({});
  return useCallback(() => setState({}), []);
};
