Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't pass null to Charts children #457

Open
brandly opened this issue Oct 23, 2020 · 1 comment
Open

Can't pass null to Charts children #457

brandly opened this issue Oct 23, 2020 · 1 comment

Comments

@brandly
Copy link
Contributor

brandly commented Oct 23, 2020

🐛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:

React.Children.forEach(this.props.children, child => {
if (child === null) return;

but there's no check here:

React.Children.forEach(charts.props.children, chart => {
if (!_.has(chart.props, "visible") || chart.props.visible) {

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:

  1. Pass a null into the children for a <Charts> instance
  2. 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?

@f3rmat
Copy link

f3rmat commented Nov 14, 2020

Had this issue recently. One workaround is to use the visible prop.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants