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

Error: Cannot read property "name" from undefined #2391

Closed
mordechaim opened this issue Jul 27, 2022 · 3 comments · Fixed by #2682 · 4 remaining pull requests
Closed

Error: Cannot read property "name" from undefined #2391

mordechaim opened this issue Jul 27, 2022 · 3 comments · Fixed by #2682 · 4 remaining pull requests
Assignees
Labels
Type: Bug 🐛 Oh no! A bug or unintentional behavior

Comments

@mordechaim
Copy link

Describe the bug
Victory blows up when you include a string or number as a child of VictoryChart.
The usual case where we might have a string is when we render a child conditionally and the condition is falsey with a 0 or empty string.

The error message in the header of this issue is from Victory Native, but, as pointed out in this comment it happens in Victory DOM as well:

Unhandled Runtime Error TypeError: Cannot read properties of undefined (reading 'name')

The line of code responsible for this:

const childName = child.props.name || `${childRole}-${names[index]}`;

It assumes the child always has props but that's not the case for strings or numbers.

Victory version
[email protected]

To Reproduce
Try rendering this:

<VictoryChart>
    a
</VictoryChart>

Expected behavior
In the process of collecting names, children as such should be ignored.

Smartphone (please complete the following information):

  • Device: Samsung S9
  • OS: Android 9
@mordechaim mordechaim added the Type: Bug 🐛 Oh no! A bug or unintentional behavior label Jul 27, 2022
@dlwsacrez
Copy link

following

@dellwatson
Copy link

dellwatson commented Apr 3, 2023

Still encounter this issue. im copying the code from example https://formidable.com/open-source/victory/gallery/stream-graph/
to codesandbox

@carbonrobot
Copy link
Contributor

Fixed in #2536. Will be released in the next minor version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment