-
Notifications
You must be signed in to change notification settings - Fork 507
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
automatically provide localised Date for SSR in RelativeTime #4305
automatically provide localised Date for SSR in RelativeTime #4305
Conversation
🦋 Changeset detectedLatest commit: ff29e49 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
db5e8a1
to
79e23a9
Compare
79e23a9
to
5eaee82
Compare
size-limit report 📦
|
const localeOptions: Intl.DateTimeFormatOptions = {month: 'short', day: 'numeric', year: 'numeric'} | ||
function RelativeTime({date, ...props}: RelativeTimeProps) { | ||
return ( | ||
<RelativeTimeComponent {...props} date={date}> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When I pass datetime
instead of date
, like <RelativeTime datetime="2024-03-10T16:30:00-08:00" />
in a sample app, it doesn't render any date in SSR. Seems like the props return undefined. Is there anything I am missing here? 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've fixed this and added tests to confirm.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible to write a test that confirms the date is localized correctly in non English-speaking locales?
It won't be as the aim is to ensure it is localised to a fixed locale, so as not to impact caching. |
* automatically provide localised Date for SSR in RelativeTime * changeset * fix and add tests * format * fix types
Closes #4361
Changelog
New
<RelativeTime/>
now renders dates in SSR.Changed
Removed
Rollout strategy
Testing & Reviewing
Merge checklist