import { createContext, useContext, useEffect, useState } from "react";

const IsHydratedContext = createContext(false);

export const IsAppHydratedProvider: React.FC<{ children: React.ReactNode }> = ({ children }) => {
  const [firstRender, setFirstRender] = useState(false);

  useEffect(() => {
    setFirstRender(true);
  }, []);

  return <IsHydratedContext.Provider value={firstRender}>{children}</IsHydratedContext.Provider>;
};

export const useIsAppHydrated = () => useContext(IsHydratedContext);
