amannn / next-intl

🌐 Internationalization (i18n) for Next.js
https://next-intl-docs.vercel.app
MIT License
2.58k stars 236 forks source link

formatter.dateTime is not a function #1304

Closed stefnto closed 2 months ago

stefnto commented 2 months ago

Description

In an async server component I make a new Date object, initialize the formatter and use the formatter.dateTime function as covered in the docs, but I get the Error: format.dateTime is not a function const format = getFormatter(locale); const dateTime = new Date("2024-08-27T10:15:30Z"); console.log(format.dateTime(dateTime, {hour: 'numeric', minute: 'numeric'}));

Verifications

Mandatory reproduction URL

https://github.com/stefnto/next-intl-bug-repro-app-router-format.dateTime-error

Reproduction description

Steps to reproduce:

  1. Clone Repo
  2. Start dev server
  3. See error when opening dev server (see TestComponent.jsx)

Expected behaviour

I expected the page to render normally as in the docs

amannn commented 2 months ago

I can unfortunately not see TestComponent.jsx in your repo. Based on your description, you're likely missing the await keyword when calling getFormatter.

github-actions[bot] commented 2 months ago

Thank you for your report!

Unfortunately, the reproduction is missing or incomplete, and as such we cannot investigate this issue. Please add a reproduction to the issue, otherwise it will be closed automatically.

Templates:

Creating a good bug report takes time.

To help us resolve the issue quickly, please simplify the reproduction as much as possible by removing any unnecessary code, files, and dependencies that are not directly related to the problem. The easier it is for us to see the issue, the faster we can help you.

Apart from the reproduction, make sure to include the precise steps on how to reproduce the issue, e.g.:

  1. Open reproduction
  2. Click on …
  3. See error: …

Thank you for your understanding!

FAQ **"I've included a reproduction, what is missing?"** This comment might have been added because your reproduction doesn't point to a destination where the issue can be reproduced. Please make sure that the latest changes were saved in the reproduction and that the link is correct.
stefnto commented 2 months ago

Owner

I can unfortunately not see TestComponent.jsx in your repo. Based on your description, you're likely missing the await keyword when calling getFormatter.

That was it, thank you!