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.

Warning: Prop `className` did not match.

See original GitHub issue

I have been having this issue since last night, i did some research but couldn’t find any solution

I’m not using Material ui or Styled components

CustomLink

import { withRouter } from "next/router";
import Link from "next/link";
import React, { Children } from "react";
import cx from "classnames";

const ActiveLink = ({ router, children, ...props }) => {
  const child = Children.only(children);

  const className = cx(child.props.className, {
    [props.activeClassName]: router.asPath === props.as && props.activeClassName
  });

  delete props.activeClassName;

  return <Link {...props}>{React.cloneElement(child, { className })}</Link>;
};

export default withRouter(ActiveLink);

Nav.js


import "../../static/styles/Nav.scss";

const Nav = () => {
  return (
    <nav className="navbar">
      <Link
        href="/player?name=xXSARKURDZz&platform=psn"
        as="/player/psn/xXSARKURDZz"
        activeClassName="navbar__item-active"
      >
        <a className="navbar__item">Profile</a>
      </Link>

      <Link
        href="/gambit?name=xXSARKURDZz&platform=psn"
        as="/player/psn/xXSARKURDZz/gambit"
        activeClassName="navbar__item-active"
      >
        <a className="navbar__item">Gambit</a>
      </Link>
    
    </nav>
  );
};

export default Nav;

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:35 (10 by maintainers)

github_iconTop GitHub Comments

154reactions
Sergioamjrcommented, Sep 30, 2019

I fixed this issue editing my .babelrc file to

{
  "presets": ["next/babel"],
  "plugins": [
    [
      "styled-components",
      { "ssr": true, "displayName": true, "preprocess": false }
    ]
  ]
}
11reactions
diegomjassocommented, May 5, 2020
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 ‍ ‍
Warning : Prop `className` did not match. Server: Client: This is probably one of the most annoying problem with ...
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 - CodeSandbox
VS Code's tsserver was deleted by another application such as a misbehaving virus detection tool. Please reinstall VS Code. Manage Extension.
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