생성:2024-08-11마지막 업데이트:2025-06-29
이 문서를 원하는 AI 어시스턴트에 참조하세요ChatGPTClaudeDeepSeekGoogle AI modeGeminiPerplexityMistralGrok
이 페이지와 원하는 AI 어시스턴트를 사용하여 문서를 요약합니다
이 페이지의 콘텐츠는 AI를 사용하여 번역되었습니다.
영어 원본 내용의 최신 버전을 보기Edit this doc
If you have an idea for improving this documentation, please feel free to contribute by submitting a pull request on GitHub.
GitHub link to the documentationCopy
Copy doc Markdown to clipboard
React 통합: useIntlayer 훅 문서
이 섹션에서는 React 애플리케이션 내에서 useIntlayer 훅을 사용하는 방법에 대해 자세히 안내하며, 효율적인 콘텐츠 현지화를 가능하게 합니다.
React에서 사용 예제
React 컴포넌트 내에서 useIntlayer 훅을 사용하는 예제:
src/app.tsx
코드 복사
코드를 클립보드에 복사
import type { FC } from "react";
import { ClientComponentExample, ServerComponentExample } from "@components";
import { IntlayerProvider } from "react-intlayer";
import { useIntlayer, IntlayerServerProvider } from "react-intlayer/server";
import { Locales } from "intlayer";
const App: FC<{ locale: Locales }> = ({ locale }) => {
const content = useIntlayer("homepage", locale);
return (
<>
<p>{content.introduction}</p>
<IntlayerProvider locale={locale}>
<ClientComponentExample />
</IntlayerProvider>
<IntlayerServerProvider locale={locale}>
<ServerComponentExample />
</IntlayerServerProvider>
</>
);
};src/components/ComponentExample.tsx
코드 복사
코드를 클립보드에 복사
import type { FC } from "react";
import { useIntlayer } from "react-intlayer";
const ComponentExample: FC = () => {
const content = useIntlayer("component-example");
return (
<div>
<h1>{content.title}</h1> {/* 제목을 표시합니다 */}
<p>{content.description}</p> {/* 설명을 표시합니다 */}
</div>
);
};src/components/ServerComponentExample.tsx
코드 복사
코드를 클립보드에 복사
import { useIntlayer } from "react-intlayer/server";
const ServerComponentExample = () => {
const content = useIntlayer("server-component");
return (
<div>
<h1>{content.title}</h1> {/* 제목을 표시합니다 */}
<p>{content.description}</p> {/* 설명을 표시합니다 */}
</div>
);
};추가 자료
- Intlayer 비주얼 에디터: 보다 직관적인 콘텐츠 관리 경험을 위해 비주얼 에디터 문서를 여기에서 참고하세요.
이 섹션은 React 애플리케이션에서 useIntlayer 훅의 통합을 구체적으로 다루며, 현지화 과정을 단순화하고 다양한 로케일 간 콘텐츠 일관성을 보장합니다.