-
Notifications
You must be signed in to change notification settings - Fork 525
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
Containers and portal refactor #2799
Conversation
🦋 Changeset detectedLatest commit: b82bc5b The changes in this PR will be included in the next version bump. This PR includes changesets to release 31 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Manual testing resultsvictory-brush-containerBefore brush.container.-.before.mp4After brush.container.-.after.mp4victory-cursor-containerBefore cursor.container.-.before.mp4After cursor.container.-.after.mp4victory-selection-containerBefore selection.container.-.before.mp4After selection.container.-.after.mp4victory-voronoi-containerBefore voronoi.container.-.before.mp4After voronoi.container.-.after.mp4victory-zoom-containerBefore zoom.container.-.before.mp4After zoom.container.-.after.mp4victory-create-containerBefore create.container.-.before.mp4After create.container.-.after.mp4 |
Victory Native testing results (v36.9.2-next.3)Before before.mp4After after.mp4 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was able to get all of the web versions of the components tested and reviewed today. I did not find any major issues.
Tomorrow, I will go through the VictoryNative components as well and give final sign off if it all looks good.
As I tested and tried to learn about each component, I jotted down some notes for improvements, but I'll create those as separate issues so this PR doesn't get bogged down with things you didn't change.
Really good attention to detail on this refactor! It's a ton of code changes and looks to be really well done so far.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I finished a code review of the remaining react-native
items and did not find any issues. Wanted to complete my review by testing the native changes locally, but I'm still working on getting that set up on my computer. Watched your testing videos and those give me more confidence that everything is working correctly.
Additionally, I reviewed your responses to my previous comments and they all look good! 🚀
This looks good, but since the size increases 100KB, we need to wait until #2804 is merged before we merge this one. |
Description
This PR is a fairly chunky refactor of the internals of all of the container components. The component APIs should not have changed. The premise of the changes: use component composition and hooks instead of class-based inheritance for the container components.
Refactored packages include:
victory-container
This component has been completely rewritten to use React hooks and modern JS instead of relying heavily on helper functions.
victory-portal
This component has also been completely rewritten, as the old approach to creating portals did not work with refs created through
useRef
. The new portal component usesReact.createPortal
instead of the custom portal solution used previously.voronoi, selection, brush, cursor and zoom containers
The container components previously overwrote methods of the
VictoryContainer
class, however, due to this being refactored to a function in this component, the inheritance no longer worked. These components were also refactored to functions, using composition and hooks to pass the container-specific functionality to theVictoryContainer
.Before:
After:
The purpose of separating the component and its functionality via the hook is so that the containers can be combined (see victory-create-container changes).
Mutated props
Victory has a lot of prop mutation. The modified props up until now meant that to satisfy TypeScript, we would have to add a non-user facing prop to the user facing prop interface or ignore the type errors. These components now have two interfaces: one for the user facing props (e.g.
VictorySelectionContainerProps
), the other for props that get added/modified through helper functions (e.g.VictorySelectionContainerMutatedProps
).defaultEvents
The container classes had a static method called
defaultEvents
which was responsible for assigning event handlers to a specifictarget
(e.g. parent, data) in a chart. Event handling will need to be refactored at some point, however, it was out of scope for this rewrite. The defaultEvents functionality has been maintained by addingdefaultEvents
method to each of the new function components.victory-create-container
The
createContainer
andmakeCreateContainerFunction
have been totally rewritten so that instead of merging the methods of each container class, they merge the properties and children for each container through their respective hooks.Testing
To test the changes, I used the demo site to compare the functionality of the latest version of victory (v36.9.1) to the changes in this PR.
Test results (web): #2799 (comment)
Test results (native): #2799 (comment)