nivo icon indicating copy to clipboard operation
nivo copied to clipboard

'legends' argument is not being passed to the 'barLegends' function, in 'layers' in nivo/bar

Open vikrantsingh47 opened this issue 2 years ago • 0 comments

I am passing this function for 'legends' in the 'layers' for nivo/bar:

const BarLegend = ({ height, legends, width }) =>
  legends.slice(0, 7).map((legend) => (
    <BoxLegendSvg
      key={JSON.stringify(
        legend.data.map(({ id }) => {
          return id;
        })
      )}
      {...legend}
      containerHeight={height}
      containerWidth={width}
    />
  ));

(refer: https://github.com/plouc/nivo/issues/204)

i have updated @nivo/bar and @nivo/legends to latest version, but now i am getting an error saying "TypeError: legends is not iterable" after some debugging i found that 'legends' is undefined in the 'BarLegend' function above, which means that 'legends' is not being passed to the function. Can you please help with this, what could be the cause of this. fyi, i have also updated react to v 18

https://codesandbox.io/s/react-nivo-example-forked-hidxj Also, in the sandbox above, if you update the nivo/bar to the latest, you will get this error.

vikrantsingh47 avatar Jul 04 '22 06:07 vikrantsingh47