victory icon indicating copy to clipboard operation
victory copied to clipboard

Error: Cannot read property "name" from undefined

Open mordechaim opened this issue 1 year ago • 0 comments

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:https://github.com/FormidableLabs/victory/blob/2ec8d5d05f07ee4146a8ef5c782f406e7be94f09/packages/victory-core/src/victory-util/helpers.ts#L257

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 avatar Jul 27 '22 23:07 mordechaim

following

dlwsacrez avatar Sep 22 '22 20:09 dlwsacrez