Skip to content

Commit b955e6f

Browse files
committed
feat: allow passing translations to ComponentWrapper
1 parent a5fcd44 commit b955e6f

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

src/markup-components/component-wrapper.tsx

+8-7
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,21 @@
33

44
import { FunctionComponent } from "react"
55
import ReactDOMServer from "react-dom/server"
6-
import { IntlProvider } from "../react-components"
7-
import * as locales from "../locales"
6+
import {
7+
CustomTranslations,
8+
IntlProvider,
9+
SupportedTranslations,
10+
} from "../react-components"
811

9-
export type Context = {
10-
locale?: keyof typeof locales
11-
}
12+
export type Context = SupportedTranslations | CustomTranslations
1213

1314
export const ComponentWrapper = <Props extends {}>(
1415
Component: FunctionComponent<Props>,
1516
props: Props,
16-
{ locale = "en" }: Context,
17+
ctx: Context,
1718
) => {
1819
return ReactDOMServer.renderToStaticMarkup(
19-
<IntlProvider locale={locale}>
20+
<IntlProvider<typeof ctx> {...ctx}>
2021
<Component {...props} />
2122
</IntlProvider>,
2223
)

0 commit comments

Comments
 (0)