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: bug with out of sync index in createMemoryHistory #11509

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

adamgrzybowski
Copy link
Contributor

@adamgrzybowski adamgrzybowski commented Jul 28, 2023

Please provide enough information so that others can review your pull request.

Motivation

The index in createMemoryHistory may be out of sync and that causes the items array to drop entries in some cases.

Test plan

In example app, add this.log in onPopState callback, push many screens in simple stack, end up on Article screen, do one go back and one forward actions with browser buttons, click POP SCREEN . You will end up in the initial page instead of the previous screen you were at.

example.mov

The change must pass lint, typescript and tests.

Note

I've added a commit to log createMemoryHistory items to make it easier to see what's actually going on. It can be removed before merging.

To see the logs you have to uncomment the line 238 in createMemoryHistory

@netlify
Copy link

netlify bot commented Jul 28, 2023

Deploy Preview for react-navigation-example ready!

Name Link
🔨 Latest commit 99b1615
🔍 Latest deploy log https://app.netlify.com/sites/react-navigation-example/deploys/64f8a28ee5e2b100076f5cbc
😎 Deploy Preview https://deploy-preview-11509--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.

@codecov-commenter
Copy link

codecov-commenter commented Jul 31, 2023

Codecov Report

Patch coverage: 25.00% and project coverage change: -0.56% ⚠️

Comparison is base (36d19bd) 75.72% compared to head (1e840e4) 75.16%.

❗ Current head 1e840e4 differs from pull request most recent head 99b1615. Consider uploading reports for the commit 99b1615 to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #11509      +/-   ##
==========================================
- Coverage   75.72%   75.16%   -0.56%     
==========================================
  Files         198      190       -8     
  Lines        5795     5747      -48     
  Branches     2268     2263       -5     
==========================================
- Hits         4388     4320      -68     
- Misses       1360     1380      +20     
  Partials       47       47              
Files Changed Coverage Δ
packages/native/src/createMemoryHistory.tsx 85.26% <25.00%> (-5.85%) ⬇️

... and 36 files with indirect coverage changes

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

Copy link
Member

@satya164 satya164 left a comment

Choose a reason for hiding this comment

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

Thanks for the PR. Can you add a test for this under example/e2e/tests?

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

4 participants