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.

using toLocaleString in markup throws checksum error

See original GitHub issue

Here is the problem I have a piece of code inside one of my components: <span>{info.minPrice.toLocaleString('fa')} تومان به بالا </span>

when I run the application I get this error:

Warning: React attempted to reuse markup in a container but the checksum was invalid. 
This generally means that you are using server rendering and the markup generated on 
the server was not what the client was expecting. React injected new markup to compensate
 which works but you have lost many of the benefits of server rendering. Instead, figure out 
why the markup being generated is different on the client or server:
 (client) react-text: 1921 -->۲٬۵۳۴٬۹۰۰<!-- /react
 (server) react-text: 1921 -->2,534,900<!-- /react

nothing else is involved in this problem if I simply remove .toLocaleString function It will work without any errors.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
blistokcommented, Jul 22, 2017

@iamsoorena This is not Next.js related issue. It has to do with Node’s poor internationalization support (node had intl issues since always); so what’s going on in your case is that server side you render number 16: node-fa while client side you render ۱۶.

Assuming you are dealing only with Farsi, I think your best bet would be to use persianjs package, and then you can have something like:

import React from 'react';
import persianJs from 'persianjs';

export default () => (
  <div>
    <span>{persianJs('16').englishNumber().toString()}</span>
  </div>
);
0reactions
iamsoorenacommented, Jul 22, 2017

Thanks a lot @Blistok .

Read more comments on GitHub >

github_iconTop Results From Across the Web

using toLocaleString in markup throws checksum error #2590
Warning: React attempted to reuse markup in a container but the checksum was invalid. This generally means that you are using server ...
Read more >
How to avoid React markup checksum warnings when ...
I know that's why it's happening, but I'm rendering something that's inherently progressing. The error is introduced between the time the server finishes ......
Read more >
js format date locale Code Example - Code Grepper
tolocaledatestring throws exception · null error due to delay in api response · API. · find out process using port windows · how...
Read more >
WjBarcodeDataMatrixEcc000 Class | Wijmo API - GrapeCity
Use the wj-barcode-data-matrix-ecc000 component to add DataMatrixEcc000 controls to your Angular 2 applications. For details about Angular 2 markup syntax, ...
Read more >
Throws - Markup Formatting Reference - Apple Developer
Throws. Add the Throws section to Quick Help for a symbol using the Throws delimiter. Use the throws section to specify any errors...
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