storybookjs / telejson

🛰 JSON parse & stringify with support for cyclic objects, functions, dates, regex, infinity, undefined, null, NaN, Classes, Instances
MIT License
169 stars 29 forks source link

[Bug]: ChartJS's _meta is breaking storybook: Converting circular structure to JSON #95

Closed genesiscz closed 1 year ago

genesiscz commented 1 year ago

Describe the bug

All storybook pages including Charts from ChartJS are, most of the time causing circular reference which then breaks the JSON.stringify call. Shouldn't telejson be able to deal with such stuff?

image

image

Example of the code that does this:


<Line
        options={{
          scales: {
            xAxes: [
              {
                gridLines: {
                  display: false,
                },
              },
            ],
            yAxes: [
              {
                gridLines: {
                  display: false,
                },
              },
            ],
          },
          legend: {
            display: false,
          },
          fill: false,
          tension: 1,
        }}
        data={{
      labels: ["1.5. 2022", "", "", "", "", "", "", "31.5. 2022"],
      datasets: [
        {
          id: 1,
          data: [0, 15, 25, 45, 35, 75, 25, 28],
          borderColor: "#ff9800",
          backgroundColor: "#f9f9fa",
        },
        {
          id: 2,
          data: [0, 0, 45, 42, 27, 35, 80, 35],
          borderColor: "#ffec4a",
          backgroundColor: "#f9f9fa",
        },
      ],
    }}
 />

Steps to reproduce the behavior

  1. Open storybook story with such a component
  2. See error

Expected behavior

Storybook handles the ciruclar reference without throwing the error

Screenshots and/or logs

Already included.

Environment

Additional context

--

genesiscz commented 1 year ago

My bad, the chartjs version was old..