Assembless / react-littera

🌐 Modern react library for managing translations.
MIT License
19 stars 1 forks source link

Locale detection crashes app in SSR #11

Closed DRFR0ST closed 3 years ago

DRFR0ST commented 3 years ago

Describe the bug The detectLocale feature is crashing server side rendered apps because window is not available in SSR.

To Reproduce Steps to reproduce the behavior:

  1. In a SSR app, add detectLocale prop to LitteraProvider.
  2. Attempt building the app.
  3. See error: 'window' is not available during server side rendering.

Expected behavior Should successfuly build the SSR app.

Potential fix The bug might be fixed by checking if window is defined. In case it's not, log an error to the console stating detectLocale is not supported in SSR.

Additional context Reproduced in Gatsby with react-littera@2.2.0.