Created
January 28, 2023 08:15
-
-
Save n4bb12/186b317529150e875c6ddfdf0277f795 to your computer and use it in GitHub Desktop.
Next.js PageProps Context
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { createContext, useContext } from "react" | |
import { RootLayoutData } from "src/data/types" | |
export const pagePropsContext = createContext({}) | |
export const PagePropsProvider = pagePropsContext.Provider | |
export function usePageProps<T>() { | |
return useContext<T & RootLayoutData>(pagePropsContext as any) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment