Last active
January 11, 2022 09:48
-
-
Save vkbansal/c7655ae813d903c62ba93b95308defc8 to your computer and use it in GitHub Desktop.
String Externalisation Snippets
This file contains hidden or 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
// StringsContext.tsx | |
import { createContext } from "react"; | |
// initialize the context | |
const StringsContext = createContext({}); | |
// props for StringsContextProvider | |
export interface StringsContextProviderProps { | |
data: Record<string, any>; | |
} | |
// a wrapper for `StringsContext.Provider` for better API | |
export function StringsContextProvider( | |
props: React.PropsWithChildren<StringsContextProviderProps> | |
) { | |
return ( | |
<StringsContext.Provider value={props.data}> | |
{props.children} | |
</StringsContext.Provider> | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment