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.

Recharts - Warning: Prop `id` did not match. Server:

See original GitHub issue

Bug report

Describe the bug

When using rechart I am getting a mismatch error between server and client. The props that are mismatching seem to change arbitrary, sometimes it’s id but I also had other cases, where it was y. image

To Reproduce:

  1. Clone Repo
  2. yarn install
  3. yarn dev
  4. navigate to http://localhost:3030/sample with open console

Expected behavior

No warning in the console.

Screenshots

Added in the repo.

System information

  • OS: MacBookPro 16"
  • Browser (if applies): Chrome
  • Version of Next.js: 9.3.6
  • Version of Node.js: 13.13.0

Additional context

I had a similar problem with react-bootstrap. I would really appreciate a blogpost or extended documentation that explains what is happening here.

Issue Analytics

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

github_iconTop GitHub Comments

57reactions
jamesmosiercommented, May 14, 2020

It looks like some components just can’t be server rendered with recharts https://github.com/recharts/recharts/issues/359

One way around this is to not server render your chart:

import dynamic from 'next/dynamic'

// components/MyChart.js contains the recharts chart
const MyChart = dynamic(
    () => import('../components/MyChart'),
    { ssr: false }
  )

export default function Example() {
  return <MyChart />;
}
4reactions
brunocrosiercommented, May 14, 2020

This is a generic Next.js warning that happens when the DOM in the client does not exactly match the DOM that was rendered on the server. In this case, you’re seeing it because the recharts id is different on the client side. It’s not a serious error so the easiest option is probably to ignore it.

Someone else might be able to shed more light on how to make the error go away, but I hope this explains why you’re seeing it

Read more comments on GitHub >

github_iconTop Results From Across the Web

how to resolve "Prop `id` did not match. Server: "react-tabs-30 ...
This error means that something on the server is different from the Client. This can happen if the client does a re-render. For...
Read more >
Common Errors in React JS Project Why It Happens?, What ...
Warning: Prop id did not match. ... The recharts graph data while running the page server-side rendering is failed. that's why it's happened ......
Read more >
how to resolve "Prop `id` did not match. Server: "react-tabs-30 ...
This error means that something on the server is different from the Client. This can happen if the client does a re-render. For...
Read more >
Warning: Prop 'Id' Did Not Match. Using Tinymce With Next Js
This is a generic Next.js warning that happens when the DOM in the client does not exactly match the DOM that was rendered...
Read more >
Rechart を Next.js で使うと「Warning: Prop id did not ... - Qiita
これは Next.js の一般的な警告です。 クライアントの DOM とサーバーでレンダリングされた DOM が正確に一致しない場合に発生します。この場合、recharts ...
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