Created
January 11, 2022 09:56
-
-
Save vkbansal/26dc10c5bda51e2dd0502134edd7ff20 to your computer and use it in GitHub Desktop.
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 | |
export interface LocaleStringProps extends React.HTMLAttributes<any> { | |
strKey: string; | |
as?: keyof JSX.IntrinsicElements; | |
} | |
export function LocaleString(props: LocaleStringProps): React.ReactElement { | |
const { strKey, as, ...rest } = props; | |
const { getString } = useLocaleStrings(); | |
const Component = as || "span"; | |
return <Component {...rest}>{getString(strKey)}</Component>; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment