Can't pass null to Charts children
🐛Bug report
Describe the bug
I want to do this:
<Charts>
{!hasDuplicateTimestamps && (
<LineChart
axis={key}
series={series}
columns={columns}
style={style}
/>
)}
<ScatterChart
axis={key}
series={series}
columns={columns}
style={style}
/>
</Charts>
I might have multiple events at a given timestamp. If I do, I don't want to render a line.
Most places where children are looped over, nulls are checked:
https://github.com/esnet/react-timeseries-charts/blob/aa9c9b368100d78337b562d9e2833f2d90d9de3d/src/components/ChartRow.js#L312-L313
but there's no check here:
https://github.com/esnet/react-timeseries-charts/blob/aa9c9b368100d78337b562d9e2833f2d90d9de3d/src/components/ChartRow.js#L316-L317
resulting in this stack trace:
Uncaught (in promise) TypeError: Cannot read property 'props' of null
at ChartRow.js:377
at forEachSingleChild (react.development.js:1118)
at traverseAllChildrenImpl (react.development.js:1007)
...
To Reproduce Steps to reproduce the behavior:
- Pass a
nullinto thechildrenfor a<Charts>instance - View crash
Expected behavior
nulls are handle. I believe it's just a matter of adding if (chart === null) return; to line 317 of ChartRow.js
want me to send a PR?
Had this issue recently. One workaround is to use the visible prop.