Skip to content

Conversation

@philibea
Copy link
Collaborator

@philibea philibea commented Jan 5, 2024

Add the possibility to avoid useless re-render at first render of the provider, i add aloadDateLocale props which is non async and will act as a default value of dateFns based on the current value of the user.

   loadDateLocaleAsync = async (locale: string) => {
      if (locale === 'en') {
        return (await import('date-fns/locale/en-GB')).enGB
      }
      if (locale === 'fr') {
        return (await import('date-fns/locale/fr')).fr
      }

      if (locale === 'es') {
        return (await import('date-fns/locale/es')).es
      }

      return (await import(`date-fns/locale/en-GB`)).enGB
    },
import { enGB, fr as frDateFns } from 'date-fns/locale'

 loadDateLocale = (locale: string) => {
      if (locale === 'en') {
        return enGB
      }
      if (locale === 'fr') {
        return frDateFns
      }

      return enGB
    },

@philibea philibea added the enhancement New feature or request label Jan 5, 2024
@philibea philibea self-assigned this Jan 5, 2024
@changeset-bot
Copy link

changeset-bot bot commented Jan 5, 2024

🦋 Changeset detected

Latest commit: f1a5071

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@scaleway/use-i18n Minor

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

@codecov
Copy link

codecov bot commented Jan 5, 2024

Codecov Report

Attention: 1 lines in your changes are missing coverage. Please review.

Comparison is base (ebdac83) 97.94% compared to head (f1a5071) 97.58%.

Files Patch % Lines
packages/use-i18n/src/usei18n.tsx 50.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1762      +/-   ##
==========================================
- Coverage   97.94%   97.58%   -0.36%     
==========================================
  Files          30       30              
  Lines         828      829       +1     
  Branches      123      124       +1     
==========================================
- Hits          811      809       -2     
- Misses          6        7       +1     
- Partials       11       13       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@philibea philibea merged commit d73b2b1 into main Jan 5, 2024
@philibea philibea deleted the fix-i18n-render branch January 5, 2024 15:11
@github-actions github-actions bot mentioned this pull request Jan 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants