0.1.0 • Published 8 months ago

@-ft/use-persist v0.1.0

Weekly downloads
-
License
MIT
Repository
github
Last release
8 months ago

use-persist - react usePersist hook

have something like member variable of class component, in function component.

Usage

import { usePersist } from '@-ft/use-persist';

function AppContextProvider({ children }) {
  const persist = usePersist(null);
  useEffect(() => {
    persist.current = initializeSomething();
    return () => {
      persist.current.dispose();
      persist.current = null;
    };
  }, []);
  return (
    <AppContext.Provider value={persist.current}>
      {children}
    </AppContext.Provider>
  );
}