[x] This is not a victory-native specific issue. (Issues that only appear in victory-native should be opened here)
[x] I have read through the FAQ and Guides before asking a question
[x] I am using the latest version of Victory
[x] I've searched open issues to make sure I'm not opening a duplicate issue
If the following things are true:
VictoryChart, VictoryAxis, VictoryGroup, VictoryLine and VictoryVoronoiContainerVictoryAxis _before_ any VictoryGroupVictoryGroup children in the VictoryChart (e.g., click a button to display a second line)VictoryLine (inside of the VictoryGroup)Then Victory crashes with an error similar to:
Invariant Violation
Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined. You likely forgot to export your component from the file it's defined in.
Check the render method of `VictoryVoronoiContainer`.
Surprisingly, if I move the VictoryAxis _after_ all VictoryGroup elements than it works as expected. The other workaround I found is to add a key to VictoryChart that will force it to re-render the entire component if the number of groups change.
I had been digging into this before.
I think there might be an issue somewhere around getMutationObject as the behavior I was noticing was that every prop was being replaced with {'data': { 'active' : true}} but unfortunately I haven't gotten a chance to dig deeper
@MrHen thanks for the reproduction. @Shadowblade911 is correct that this issue is related to activating data on the newly added group. I will need to look into why this is throwing an error when used with dynamic VictoryGroup children. In the meantime you have a couple options:
1) set activateData={false} on VictoryVoronoiContainer if you only need to activate labels
2) Don't nest the dynamic children you are adding inside VictoryGroup
Thanks @boygirl. Option 1 looks like something we can do in the short term. Option 2 is not viable -- the reproduction is deliberately small but we have some pretty complicated charts that cannot be unnested.
Most helpful comment
@MrHen thanks for the reproduction. @Shadowblade911 is correct that this issue is related to activating data on the newly added group. I will need to look into why this is throwing an error when used with dynamic VictoryGroup children. In the meantime you have a couple options:
1) set
activateData={false}onVictoryVoronoiContainerif you only need to activate labels2) Don't nest the dynamic children you are adding inside
VictoryGroup