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

feat: allow deep linking to reset state #8973

Merged
merged 1 commit into from
Oct 24, 2020
Merged

Conversation

satya164
Copy link
Member

@satya164 satya164 commented Oct 22, 2020

Currently when we receive a deep link after the app is rendered, it always results in a navigate action. While it's ok with the default configuration, it may result in incorrect behaviour when a custom getStateForPath function is provided and it returns a routes array different than the initial route and new route pair.

The commit changes 2 things:

  1. Add ability to reset state via params of navigate by specifying a state property instead of screen
  2. Update getStateForAction to return an action for reset when necessary according to the deep linking configuration

Closes #8952

@satya164 satya164 changed the title feat: feat: allow deep linking to reset state Oct 22, 2020
@netlify
Copy link

netlify bot commented Oct 22, 2020

Deploy preview for react-navigation-example ready!

Built with commit f6f6d2b

https://deploy-preview-8973--react-navigation-example.netlify.app

@github-actions
Copy link

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

expo.io/@react-navigation/react-navigation-example?release-channel=pr-8973

@satya164 satya164 force-pushed the @satya164/navigate-reset branch from 8ca9379 to becf99a Compare October 23, 2020 16:15
@codecov-io
Copy link

codecov-io commented Oct 23, 2020

Codecov Report

Merging #8973 into main will increase coverage by 0.26%.
The diff coverage is 92.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #8973      +/-   ##
==========================================
+ Coverage   73.71%   73.98%   +0.26%     
==========================================
  Files         131      131              
  Lines        3276     3306      +30     
  Branches     1017     1008       -9     
==========================================
+ Hits         2415     2446      +31     
- Misses        751      752       +1     
+ Partials      110      108       -2     
Impacted Files Coverage Δ
packages/native/src/useLinkTo.tsx 0.00% <0.00%> (ø)
packages/native/src/useLinking.native.tsx 50.94% <0.00%> (ø)
packages/native/src/useLinking.tsx 78.23% <0.00%> (ø)
packages/core/src/getActionFromState.tsx 97.50% <96.77%> (-2.50%) ⬇️
packages/core/src/useNavigationBuilder.tsx 99.25% <100.00%> (+0.83%) ⬆️
...ges/core/src/__tests__/__fixtures__/MockRouter.tsx 97.14% <0.00%> (+2.85%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f51086e...f6f6d2b. Read the comment docs.

@satya164 satya164 force-pushed the @satya164/navigate-reset branch 3 times, most recently from 99832d8 to e09bc56 Compare October 24, 2020 01:34
Currently when we receive a deep link after the app is rendered, it always results in a `navigate` action. While it's ok with the default configuration, it may result in incorrect behaviour when a custom `getStateForPath` function is provided and it returns a routes array different than the initial route and new route pair.

The commit changes 2 things:

1. Add ability to reset state via params of `navigate` by specifying a `state` property instead of `screen`
2. Update `getStateForAction` to return an action for reset when necessary according to the deep linking configuration
@satya164 satya164 force-pushed the @satya164/navigate-reset branch from e09bc56 to f6f6d2b Compare October 24, 2020 01:40
@satya164 satya164 marked this pull request as ready for review October 24, 2020 13:26
@satya164 satya164 merged commit 7f3b27a into main Oct 24, 2020
@satya164 satya164 deleted the @satya164/navigate-reset branch October 24, 2020 13:27
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.

react-navigation is ignoring the routes returned by getStateFromPath
2 participants