question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Dynamic content in locale file is loaded in SSR then reloaded on the client during hydration

See original GitHub issue

Version

v6.8.1

Reproduction link

https://none

Steps to reproduce

  • Enable lazy: true in nuxt.config.js.
  • Create an /locales/en.js
  • In the en.js file, add a message: Math.random() translation
  • In a template, display {{ $t('message') }}
  • Reload the browser
  • Observe the page loads with the translations already applied in SSR, showing a random number
  • Observe that a few moments later, hydration happens and the random number is replaced with a new number

What is expected ?

Only the SSR version of the translations would be applied and hydration would not actually update the translations.

What is actually happening?

Hydration is updating the translations, changing the content from what SSR generates.

Additional comments?

The reason this came up is we’re using a lorem ipsum module to quickly mock up fake content in our translations. Having the content change suddenly after first load is jarring.

<div align="right">This bug report is available on Nuxt community (#c436)</div>

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:10

github_iconTop GitHub Comments

1reaction
rchlcommented, Apr 13, 2020

It sounds like a good idea and might be a good base for fixing some other issues.

There is something that makes it non-trivial though - language files can export function in which case we have to pass context object to them and we can’t do that if we are gonna process those when Nuxt module’s code runs (which we would have to do to fix this).

We could potentially treat those two cases differently but not sure…

Are you exporting plain object or function from your language files?

0reactions
rchlcommented, Aug 4, 2020

Released in v6.13.3

Read more comments on GitHub >

github_iconTop Results From Across the Web

Dynamic content in locale file is loaded in SSR then reloaded ...
Only the SSR version of the translations would be applied and hydration would not actually update the translations. What is actually happening?
Read more >
Localized Server-Side Rendering with React | Phrase
Learn here how to localize a React app made with SSR. ... on the server side, and then hydrated on the client side...
Read more >
Web Components in Server-Side Rendered (SSR) and Static ...
All the client has to do is hydrate the components and make them functional. The less dynamic content the client renders, the better...
Read more >
React 18: Hydration failed because the initial UI does not ...
I have been experiencing the same problem lately with NextJS and i am not sure if my observations are applicable to other libraries....
Read more >
Fixing Gatsby's rehydration issue - LogRocket Blog
This post shows you how to overcome a rehydration issue when using server side rendering in Gatsby to makes ure your application runs...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found