-
Notifications
You must be signed in to change notification settings - Fork 378
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
991f8fe
commit 2493e08
Showing
3 changed files
with
16 additions
and
12 deletions.
There are no files selected for viewing
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
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 }} /> | ||
} |
13 changes: 1 addition & 12 deletions
13
packages/react/src/index-rsc.tsx → packages/react/src/index-rsc.ts
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
File renamed without changes.