wojtekmaj / react-calendar

Ultimate calendar for your React app.
https://projects.wojtekmaj.pl/react-calendar
MIT License
3.46k stars 497 forks source link

Warning: Prop `aria-label` did not match #891

Closed Muhameti-centralsoft closed 10 months ago

Muhameti-centralsoft commented 10 months ago

Before you start - checklist

Description

The first time the calendar is displayed I get the following warning.

Warning: Prop aria-label did not match. Server: "August 1, 2023" Client: "1 August 2023"

image

Steps to reproduce

Go to the page where react-calendar is displayed and maybe refresh the page.

Expected behavior

There is no warning

Actual behavior

There is a warning

Additional information

No response

Environment

wojtekmaj commented 10 months ago

In SSR mode, the server side rendered component has no way of knowing what the browser's preferred locale might be, so it defaults to its own, likely 'en-US'. Browser's preferred locale is passed to the server in Accept-Language HTTP header. You would need to figure out which locale to use based on this header. get-user-locale might help.

Easier alternative: provide hardcoded locale.

Muhameti-centralsoft commented 10 months ago

Many thanks! It solved the issue for me :)