Next.js Discord

Discord Forum

NextJS Internationalization

Unanswered
Tramp ant posted this in #help-forum
Open in Discord
Tramp antOP
Hi, I have just implemented my Internationalization and I do it on the main page and pass it though to the components so its not loaded multiple times but I am writing unit tests now and they are having massive issues what is the best way to pass in the intl?

5 Replies

Tramp antOP
  it("given isLoginValid is true render UserNavbar", () => {
    render(<CustomNavbar isLoginValid intl={{}} />);

    const userNavbar = screen.getByTestId("user-navbar");

    expect(userNavbar).toBeInTheDocument();
  });
export default async function CustomNavbar(props: CustomNavbarTypes) {
  return <DefaultNavbar intl={props.intl}/>
}
type Props = {
  params: {
    lang: Locale
  }
}

export default async function Home({params: {lang}}: Props) {
  const intl = await getDictionary(lang)
  return (
    <main>
      <CustomNavbar intl={intl} />
    </main>
  )
}
Error: Uncaught [Error: Objects are not valid as a React child (found: [object Promise]). If you meant to render a collection of children, use an array instead.]