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.

Next.js - className doesn't match from Server to Client

See original GitHub issue

In Next.js there’s a mismatch between the classes printed in className on the Server and the ones in Client.

The Client adds a space at the end of the concatenation of classes, causing the mismatch.

In example: Warning: Prop className did not match. Server: "svg-inline--fa fa-mug-saucer" Client: "svg-inline--fa fa-mug-saucer "

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
robmadolecommented, Apr 12, 2022

@FunctionDJ ah, sorry we’ve got two different bugs here. Will you create an issue with your error separate from this? Your issues is not related to the OP. I think I have a fix for your issue once you do that.

@redbaron76 it’s the extra space that is causing a problem for you. We’ll see if we can get that taken care of.

0reactions
ivan-kleshnincommented, Apr 22, 2022

I have the same warning about the pulse prop:

Prop `className` did not match. 
Server: "svg-inline--fa fa-spinner fa-pulse " 
Client: "svg-inline--fa fa-spinner "

With spin working fine in the same setup:

<FontAwesomeIcon
  ...
  pulse={pulse}
  spin={spin}
  ...
/>

It might be related to the unfinished internal migration from pulse to spinPulse but I’m not sure. Should I create a new issue?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Warning: Prop `className` did not match. when using styled ...
That error is showing you the class that is being created by your styled-components library on the server and how it is different...
Read more >
Warning: Prop className did not match. #7322 - GitHub
It appears to be an issue that backend generates styled component but client doesn't get it/doesn't use it and instead of using server...
Read more >
Fixing ClassName did not match error - DEV Community ‍ ‍
babelrc in the root directory and configure it. Here's the config file. Restart your server and refresh your server and you should be...
Read more >
Solving the Styled Components Warning in Next.JS with Babel
Warning: Prop `className` did not match. Server: “fs-fdsf” Client: “sd-dfasj”. The combination of Next.JS and Styled Components is truly ...
Read more >
Prop `className` did not match. Server.... react js next js ...
[Solved]-Prop `className` did not match. Server.... react js next js-Reactjs. Search. score:0. const style = (<style jsx global className='theme'>{` body ...
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