-
Notifications
You must be signed in to change notification settings - Fork 524
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
Migrate to new context API #1461
Migrate to new context API #1461
Conversation
@fabianishere I definitely appreciate the help here. I checked out your work locally, though, and it looks like this change breaks all animations. I will need to dig in more to understand why this is happening. I've had a worry for some time now that Victory's animation model might need a more significant overhaul to work correctly with the new context API :( |
Interesting, that did not occur to me. Any way to reproduce this? If I recall correctly, there are no tests for animation in the storybook. I may be able to dig into this if you would like. |
This change updates several components to pass down the global Timer object via the new React context API.
This change changes the internal Portal code to make use of a PortalContext using the new React context API.
@fabianishere you can run the demo pages w/ I'm actually taking a look at this right now, and iterating from your work. I'll push something in the next ~hour. I would love an extra set of eyes. |
@boygirl I just pushed another version. I noticed the context was not being set correctly in EDIT: Apparently the animations work when reloading the page. |
if (!this.context.getTimer) { | ||
this.getTimer().stop(); | ||
} | ||
this.timer.stop(); |
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 am not sure whether this is the correct translation here. Should the timer only be stopped by this component if it has created the timer itself?
Closing in favor of #1462. Thank you @fabianishere for all the help! |
Hi!
When running an application in StrictMode, I stumbled upon the warning that Victory is still using the legacy context API (#1442). This pull requests removes the usage of the legacy API and adds two new context types
TimerContext
andPortalContext
, which carry respectively the application's global timer and the portal context functions.Some parts of the code are not well-tested (yet), so might not be implemented correctly. In particular, no test touches the code in
zoom-helpers.js
. In this case, I assume the context passed to the function is the class instance of the component (wherethis.timer
is set).Hope this is helpful!
Fixes #1442