Nextjs tailwind Warning: Prop `className` did not match

Barty

I have getting the following warning, I am unsure of how to get it to go away:

Warning: Prop `className` did not match. 

 Server: "flex items-center justify-start my-2 p-4 text-sm w-full hover:text-white rounded-r-lg \n       

 font-medium text-white bg-gray-900 rounded-r-lg group flex items-center px-2 py-2" 

 Client: "flex items-center justify-start my-2 p-4 text-sm w-full hover:text-white rounded-r-lg \n            
 text-gray-200 hover:bg-gray-700 group flex items-center px-2 py-2"
 a

_c<@webpack-internal:///./node_modules/next/dist/client/link.js:133:27

The area where it is in my code is:

const style = {
  inactive: `text-gray-200 hover:bg-gray-700`,
  active: `font-medium text-white bg-gray-900 rounded-r-lg`,
  link: `flex items-center justify-start my-2 p-4 text-sm w-full hover:text-white rounded-r-lg`,
};

 function Items() {
   const { asPath } = useRouter();
   return (
     <ul>
      <li>
         {data.map((item) => (
           <Link href={item.link} key={item.title}>
            <a
               className={classNames(
                 `${style.link} 
                  ${item.link === asPath ? style.active : style.inactive}`,
            "group flex items-center px-2 py-2"
          )}
        >

EDIT: added more code

Mohit Maroliya B17CS036

You need to remove the classNames here

Below is the code , please check

const style = {
  inactive: `text-gray-200 hover:bg-gray-700`,
  active: `font-medium text-white bg-gray-900 rounded-r-lg`,
  link: `flex items-center justify-start my-2 p-4 text-sm w-full hover:text-white rounded-r-lg`,
};

 function Items() {
   const { asPath } = useRouter();
   return (
     <ul>
      <li>
         {data.map((item) => (
           <Link href={item.link} key={item.title}>
            <a
               className={
                 `${style.link} 
                  ${item.link === asPath ? style.active : style.inactive}
            group flex items-center px-2 py-2`
          )}
        >

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Warning: Prop `className` did not match in NextJs project and classnames package

NextJS React app styled component not rendering correct: Warning: Prop `className` did not match

How to fix "Warning: Prop className did not match" when using UIkit and NextJs

nextjs: Warning: Prop `className` did not match. Server: "x" Client: "y"

React + Material-UI - Warning: Prop className did not match

Warning: Prop `className` did not match ~ Material UI css arbitrarily breaks on reload

"Warning: Prop `className` did not match" while setting up a theme provider in Next.js

Warning "Prop `src` did not match" in React

Getting error, `Prop `className` did not match` when deploying to Heroku, but works locally

Warning: Text content did not match. Server: "I'm out" Client: "I'm in" div NEXTJS

Warning Prop `href` did not match. using react server-side-rendering

Warning: Unknown DOM property class. Did you mean className?

How do I remove this prop type warning with nextjs?

Icons for Nextjs and tailwind layout

Problems with styling Nextjs & tailwind

Prop in interpolation (tailwind, react)

Is there any way to avoid "Text content did not match" warning in SSR with React?

React Router Throwing Warning: Location "/" did not match any routes

React router is not able to handle routes and give back warning of did not match

React-loadable warning text content did not match

"Warning: Each child in a list should have a unique 'key' prop" error in NextJS

Nextjs Tailwind Marquee Component is overflowing

NextJs Tailwind header styling issue

NextJs css modules - variable in className

Tailwind css - use className custom spacing value as variable for tailwind config

How to select a specific child by className in Tailwind

Less wont apply Tailwind CSS classname with dot (.)

Nextjs with tailwind takes 8 - 16 seconds to complie

Tailwind CSS partially working in NextJS app

TOP Ranking

  1. 1

    Failed to listen on localhost:8000 (reason: Cannot assign requested address)

  2. 2

    Loopback Error: connect ECONNREFUSED 127.0.0.1:3306 (MAMP)

  3. 3

    How to import an asset in swift using Bundle.main.path() in a react-native native module

  4. 4

    pump.io port in URL

  5. 5

    Compiler error CS0246 (type or namespace not found) on using Ninject in ASP.NET vNext

  6. 6

    BigQuery - concatenate ignoring NULL

  7. 7

    ngClass error (Can't bind ngClass since it isn't a known property of div) in Angular 11.0.3

  8. 8

    ggplotly no applicable method for 'plotly_build' applied to an object of class "NULL" if statements

  9. 9

    Spring Boot JPA PostgreSQL Web App - Internal Authentication Error

  10. 10

    How to remove the extra space from right in a webview?

  11. 11

    java.lang.NullPointerException: Cannot read the array length because "<local3>" is null

  12. 12

    Jquery different data trapped from direct mousedown event and simulation via $(this).trigger('mousedown');

  13. 13

    flutter: dropdown item programmatically unselect problem

  14. 14

    How to use merge windows unallocated space into Ubuntu using GParted?

  15. 15

    Change dd-mm-yyyy date format of dataframe date column to yyyy-mm-dd

  16. 16

    Nuget add packages gives access denied errors

  17. 17

    Svchost high CPU from Microsoft.BingWeather app errors

  18. 18

    Can't pre-populate phone number and message body in SMS link on iPhones when SMS app is not running in the background

  19. 19

    12.04.3--- Dconf Editor won't show com>canonical>unity option

  20. 20

    Any way to remove trailing whitespace *FOR EDITED* lines in Eclipse [for Java]?

  21. 21

    maven-jaxb2-plugin cannot generate classes due to two declarations cause a collision in ObjectFactory class

HotTag

Archive