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: ensure latest values are used when preventRemove is triggered in usePreventRemove hook #11523

Closed
wants to merge 1 commit into from
Closed

fix: ensure latest values are used when preventRemove is triggered in usePreventRemove hook #11523

wants to merge 1 commit into from

Conversation

andrejpavlovic
Copy link

@andrejpavlovic andrejpavlovic commented Aug 5, 2023

Motivation

In react-navigation/native@6.1.7 with @react-navigation/core@6.4.9 UNSTABLE_usePreventRemove, when beforeRemove listener is triggered it, it uses old value of preventRemove parameter that's passed into the hook. By using a reference to preventRemove (and callback) we can ensure the latest value is always used.

Test plan

Describe the steps to test this change so that a reviewer can verify it. Provide screenshots or videos if the change affects UI.

The change must pass lint, typescript and tests.

@github-actions
Copy link

github-actions bot commented Aug 5, 2023

Hey @andrejpavlovic! Thanks for opening your first pull request in this repo. If you haven't already, make sure to read our contribution guidelines.

@codecov-commenter
Copy link

Codecov Report

Patch coverage: 100.00% and project coverage change: +0.02% 🎉

Comparison is base (c43208f) 75.49% compared to head (898c7e2) 75.52%.

❗ Your organization is not using the GitHub App Integration. As a result you may experience degraded service beginning May 15th. Please install the Github App Integration for your organization. Read more.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #11523      +/-   ##
==========================================
+ Coverage   75.49%   75.52%   +0.02%     
==========================================
  Files         190      190              
  Lines        5742     5748       +6     
  Branches     2261     2261              
==========================================
+ Hits         4335     4341       +6     
  Misses       1360     1360              
  Partials       47       47              
Files Changed Coverage Δ
packages/core/src/usePreventRemove.tsx 100.00% <100.00%> (ø)

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@netlify
Copy link

netlify bot commented Aug 5, 2023

Deploy Preview for react-navigation-example ready!

Name Link
🔨 Latest commit 898c7e2
🔍 Latest deploy log https://app.netlify.com/sites/react-navigation-example/deploys/64cdab2d9f97e70008230e29
😎 Deploy Preview https://deploy-preview-11523--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 configuration.

@andrejpavlovic
Copy link
Author

andrejpavlovic commented Aug 5, 2023

Nevermind, the issue is with lack of support of useLatestCallback in React Native which is used by react-navigation.

Opened the issue here: satya164/use-latest-callback#3

@github-actions
Copy link

github-actions bot commented Aug 5, 2023

Hey! This issue is closed and isn't watched by the core team. You are welcome to discuss the issue with others in this thread, but if you think this issue is still valid and needs to be tracked, please open a new issue with a repro.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants