useGlobalConf.jsx 523 B

1234567891011121314151617181920
  1. import React, { useContext } from "react";
  2. export const GlobalConfContext = React.createContext({});
  3. export const GlobalConfProvider = ({ children, ...rest }) => {
  4. const [editItem, setEditItem] = React.useState(false);
  5. const [other] = React.useState(rest);
  6. return (
  7. <GlobalConfContext.Provider value={{ editItem, setEditItem, ...other }}>
  8. {children}
  9. </GlobalConfContext.Provider>
  10. );
  11. };
  12. export const useGlobalConf = () => {
  13. return useContext(GlobalConfContext);
  14. };
  15. export default useGlobalConf;