-
Notifications
You must be signed in to change notification settings - Fork 526
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
Unable to wrap victory components into customizable components #2342
Comments
I've also tried this, even passing all the props from parent to child and it does not work. I believe that this is related to: I noticed that the above issue is closed. Is this fix going towards a specific version? |
Unless there is some workaround I'm not yet aware of, Victory doesn't currently support custom components as top-level components inside a VictoryChart component. This isn't ideal, and is definitely a reflection of some not-so-great architectural patterns we have going on right now, but basically the For now, I would encourage you to use the Victory component at the top-level when rendering inside a |
Hi guys, any solution to this problem? Can't create custom components? I've tried merging props which my custom component receives still have some weird behaviour. |
@becca-bailey Do you mean that custom components using Victory components should work if I wrap the custom components in VictoryGroup? Because that does not seem to help. Perhaps I misunderstand your wording. This really does feel like an important issue to me, I'm not looking for a repeat of the very long and hard to read file that the people at Chart.js made me write and this looked like a very promising library. |
@becca-bailey I see v37 was released a few days ago but I don't believe this included the architecture changes you mentioned above. Are these still on the roadmap? |
@robcostello1 The v37 release was a necessity for a different reason; changing the babel output target. Although v36.x made a lot of changes in the architecture, we still do not have a direct way to allow custom components. The original code of Victory was designed prior to hooks, context, and concepts like slots (9yrs ago now) so the architecture does not have a simple way to accommodate a custom component because it looks at the Type of the first child and runs logic based on that Type. For now, this feature remains on the backlog with no roadmap plan. Our hope is to move completely to functional components and use context in the future which solves this, but we have several hurdles to jump before its possible (particularly #2778). |
@carbonrobot That sould like an oversight in the design phase, is it not possbile for this library to use normal React code so the Victory components don't break on a React API update? It would make sense to me if Victory components were just regular old React components with some sugar on top. Is there any graphing library out there that does conform to React's standards and actually is composable? |
Is your feature request related to a problem? Please describe.
When I try to wrap Victory components like VictoryLine or VictoryBar, the graph is not plotted for reasons unknown.
Describe the solution you'd like
Need to get Victory component wrapped to my custom component thereby plotting chart smoothly as expected.
Describe alternatives you've considered
I tried mentioning the roles like below, but no luck.
MyCustomLine.role = 'line';
Additional context
Below is the Codesandbox link demonstrating the sample application I am trying. It contains the examples of working one wherein Victory component is directly used and not working one, wherein Victory component is wrapped up
https://codesandbox.io/s/victory-wrapper-p6ffzy?file=/src/App.tsx
Please let me know if I am missing something to get my chart plotted using my wrapped component.
The text was updated successfully, but these errors were encountered: