Explicitly provide resolved locale for all functions which need it #2523
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What's Changed
locale
is optionally user defined as a prop to DayPicker and should fallback to en-US (the default for DayPicker) when none is supplied by the user. There were several places where this default was not respected, and insteadprops.locale
was used (which can be undefined).This PR addresses the above problem by explicitly requiring
locale
as a non-optional argument everywhere it's used, similar to howdateLib
is passed around.This resolves #2509 (related discussion #2511) in where if the client application used date-fns and had a locale set through
dateFns.setDefaultOptions
, then the internal calls to date-fns within DayPicker would use this client defined default (instead of the en-US default) in the cases whereprops.locale
was being used (namelyuseCalendar
).Once we cross the threshold into DayPicker, we should always be using a resolved locale object to ensure consistency of rendered dates across components.
Type of Change
Additional Notes
Fixes #2509
Related #2511