Skip to content
This repository has been archived by the owner on Feb 8, 2020. It is now read-only.

fix: implement canGoBack for tab router #51

Merged
merged 1 commit into from
Aug 13, 2019
Merged

Conversation

satya164
Copy link
Member

@satya164 satya164 commented Aug 9, 2019

No description provided.

@satya164 satya164 requested a review from osdnk August 9, 2019 19:08
@satya164 satya164 force-pushed the @satya164/tab-can-go-back branch from 29026bd to 0e4e58c Compare August 9, 2019 19:11
@codecov-io
Copy link

Codecov Report

Merging #51 into master will increase coverage by 0.24%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #51      +/-   ##
==========================================
+ Coverage   93.04%   93.28%   +0.24%     
==========================================
  Files          21       21              
  Lines         388      387       -1     
  Branches       97       93       -4     
==========================================
  Hits          361      361              
+ Misses         26       25       -1     
  Partials        1        1
Impacted Files Coverage Δ
packages/core/src/BaseRouter.tsx 40% <ø> (+1.9%) ⬆️

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 a284ef1...0e4e58c. Read the comment docs.

@@ -211,6 +211,10 @@ export default function TabRouter({
return action.type === 'NAVIGATE';
},

canGoBack(state) {
return router.getStateForAction(state, { type: 'GO_BACK' }) !== null;
Copy link
Member Author

Choose a reason for hiding this comment

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

this gave me an idea. we don't actually need to implement this method in routers. we can instead do this to implement canGoBack:

canGoBack: () =>
        router.getStateForAction(getState(), BaseActions.goBack()) !== null ||
        (parentNavigationHelpers && parentNavigationHelpers.canGoBack()) ||
        false

Copy link
Member

Choose a reason for hiding this comment

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

idk.

@osdnk osdnk merged commit dc3495a into master Aug 13, 2019
@osdnk osdnk deleted the @satya164/tab-can-go-back branch August 13, 2019 20:10
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants