Skip to content

Commit

Permalink
feat(react): fix build
Browse files Browse the repository at this point in the history
  • Loading branch information
timofei-iatsenko committed Apr 11, 2024
1 parent 991f8fe commit 2493e08
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 12 deletions.
15 changes: 15 additions & 0 deletions packages/react/src/TransRsc.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { TransProps, TransNoContext } from "./TransNoContext"
import React from "react"
import { getI18n } from "./server"

export function TransRsc(
props: TransProps
): React.ReactElement<any, any> | null {
const i18n = getI18n()
if (!i18n) {
throw new Error(
"You tried to use `Trans` in Server Component, but i18n instance for RSC hasn't been setup.\nMake sure to call `setI18n` in root of your page"
)
}
return <TransNoContext {...props} lingui={{ i18n }} />
}
Original file line number Diff line number Diff line change
@@ -1,24 +1,13 @@
import React from "react"

export type {
TransProps,
TransRenderProps,
TransRenderCallbackOrComponent,
} from "./TransNoContext"

import { TransNoContext, TransProps } from "./TransNoContext"
import type { I18nContext } from "./I18nProvider"
import { getI18n } from "./server"

export function Trans(props: TransProps): React.ReactElement<any, any> | null {
const i18n = getI18n()
if (!i18n) {
throw new Error(
"You tried to use `Trans` in Server Component, but i18n instance for RSC hasn't been setup.\nMake sure to call `setI18n` in root of your page"
)
}
return <TransNoContext {...props} lingui={{ i18n }} />
}
export { TransRsc as Trans } from "./TransRsc"

export function useLingui(): I18nContext {
const i18n = getI18n()
Expand Down
File renamed without changes.

0 comments on commit 2493e08

Please sign in to comment.