useGlobal.js 550 Bytes
Newer Older
wuhao's avatar
wuhao committed
1 2 3
import { useState, useCallback } from "react";
export default function useGlobal() {
  const [alive, setAlive] = useState(false),
krysent's avatar
krysent committed
4 5
    [newMenus, setMenu] = useState({}),
    [storeId, setStoreId] = useState("");
wuhao's avatar
wuhao committed
6 7 8 9 10 11 12 13 14

  const changealive = useCallback((parser) => {
    setAlive(parser);
  }, []);

  const setMenuFn = useCallback((val) => {
    setMenu(val);
  }, []);

krysent's avatar
krysent committed
15 16 17 18
  const setStoreIdFn = useCallback((val) => {
    setStoreId(val);
  }, []);

wuhao's avatar
wuhao committed
19 20 21 22 23
  return {
    alive,
    changealive,
    newMenus,
    setMenuFn,
krysent's avatar
krysent committed
24 25
    setStoreIdFn,
    storeId,
wuhao's avatar
wuhao committed
26 27
  };
}