Skip to content

Drawer - Remove UNSAFE method #945

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

Merged
merged 8 commits into from
Sep 30, 2020
Merged

Conversation

Inbal-Tish
Copy link
Collaborator

Description

Swipeable - Remove 'UNSAFE_componentWillUpdate' method.

Changelog

Drawer - Swipeable - Remove UNSAFE method.

Comment on lines 430 to 432
if (this._shouldUpdateAnimatedEvent()) {
this._updateAnimatedEvent(this.props, this.state);
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't trigger updates or animations from the render method.
There're other lifecycle methods for that..

Why don't keep this logic in componentDidUpdate?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not triggering animation, it just updates the variables and it happens only once, after the first render and before the second one that is triggered by a 'setState' in the 'onLayout'. If I'll move it to the 'componentDidUpdate' it won't take effect since it will happen after the second render, and since I can't trigger render in 'componentDidUpdate' from obvious reasons...

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there's fundamental issue with the component and maybe it's a good opportunity to refactor it a little.
This hack doesn't feel unnatural to React ecosystem.

Currently we store derived animated values in the class instance (this._transX, this._showLeftAction, this._leftActionTranslate, etc..)

This forces us to store these values at the right moment so it will take into account when the next render happens.

What if instead of sorting these values we'll just implement methods that return the derived animated value separately.
For instance, we'll have a method for getTransX and getShowLeftAction and so on..
This way I believe the values should by dynamic and always derive from current state/props and might reduce us some unnecessary code

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Love it. Thanks. Done.

Comment on lines 139 to 140
this.prevProps = prevProps;
this.prevState = prevState;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why storing these?
Why not just have the check here..

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I need to check after the first render

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See my other comment, this may be redundant.

@ethanshar ethanshar merged commit bbf80bc into master Sep 30, 2020
@Inbal-Tish Inbal-Tish deleted the infra/Swipeable_remove_UNSAFE branch September 30, 2020 17:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants