Skip to content
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

fix: add additional check before running animate in componentDidUpdate #10871

Merged

Conversation

kacperkapusciak
Copy link
Member

Motivation

Changed introduced in #10767 created a regression reported in #10856 which made it impossible to close a modal with a gesture.

As we want to change pointer-events on Card in componentDidUpdate previous use of setNativeProps in this context made a lot of sense. Since setNativeProps is going to be removed in the new architecture we had to migrate it to the component state as stated in the migration guide.

This PR adds an additional closing !== prevProps.closing check on top of #10767 within componentDidUpdate in Card.tsx.

Test plan

ModalStack example

Recordings

Before

Screen.Recording.2022-09-21.at.12.35.45.mov

After

Screen.Recording.2022-09-21.at.12.34.51.mov

Issue the aforementioned PR fixed originally still works

Screen.Recording.2022-09-21.at.12.33.11.mov

@netlify
Copy link

netlify bot commented Sep 21, 2022

Deploy Preview for react-navigation-example ready!

Name Link
🔨 Latest commit 2e70da1
🔍 Latest deploy log https://app.netlify.com/sites/react-navigation-example/deploys/632aeb67281f7300094095bd
😎 Deploy Preview https://deploy-preview-10871--react-navigation-example.netlify.app/
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@github-actions
Copy link

The Expo app for the example from this branch is ready!

expo.dev/@react-navigation/react-navigation-example?release-channel=pr-10871

@codecov-commenter
Copy link

Codecov Report

Base: 75.47% // Head: 75.43% // Decreases project coverage by -0.03% ⚠️

Coverage data is based on head (2e70da1) compared to base (d20e565).
Patch coverage: 60.00% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #10871      +/-   ##
==========================================
- Coverage   75.47%   75.43%   -0.04%     
==========================================
  Files         167      167              
  Lines        5129     5130       +1     
  Branches     1985     1986       +1     
==========================================
- Hits         3871     3870       -1     
- Misses       1220     1222       +2     
  Partials       38       38              
Impacted Files Coverage Δ
packages/stack/src/views/Stack/Card.tsx 61.05% <60.00%> (-0.86%) ⬇️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@kacperkapusciak kacperkapusciak merged commit b9fb2d1 into main Oct 5, 2022
@kacperkapusciak kacperkapusciak deleted the @kacperkapusciak/fix-migrate-off-setNativeProps branch October 5, 2022 16:26
kacperkapusciak added a commit that referenced this pull request Oct 27, 2022
kacperkapusciak added a commit that referenced this pull request Nov 4, 2022
### Motivation

This PR is a third attempt to migrate setNativeProps to state in @react-navigation/stack following the official Moving setNativeProps to state guide.

After issues with the implementation of #10767 and more problems with the fix in #10871 we had to take a step back and rethink where the problem lays with these implementations.

The solution was to move the state inside the CardSheet component and use useImperativeHandle to hoist a setter function up to Card to avoid triggering a rerender during Card animate function.
kacperkapusciak added a commit that referenced this pull request Nov 4, 2022
kacperkapusciak added a commit that referenced this pull request Nov 4, 2022
### Motivation

This PR is a third attempt to migrate setNativeProps to state in @react-navigation/stack following the official Moving setNativeProps to state guide.

After issues with the implementation of #10767 and more problems with the fix in #10871 we had to take a step back and rethink where the problem lays with these implementations.

The solution was to move the state inside the CardSheet component and use useImperativeHandle to hoist a setter function up to Card to avoid triggering a rerender during Card animate function.
kacperkapusciak added a commit to josemak25/react-navigation that referenced this pull request Dec 15, 2022
kacperkapusciak added a commit to josemak25/react-navigation that referenced this pull request Dec 15, 2022
### Motivation

This PR is a third attempt to migrate setNativeProps to state in @react-navigation/stack following the official Moving setNativeProps to state guide.

After issues with the implementation of react-navigation#10767 and more problems with the fix in react-navigation#10871 we had to take a step back and rethink where the problem lays with these implementations.

The solution was to move the state inside the CardSheet component and use useImperativeHandle to hoist a setter function up to Card to avoid triggering a rerender during Card animate function.
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.

None yet

3 participants