Skip to content

Commit

Permalink
Use getActiveRoute in isActiveRoute
Browse files Browse the repository at this point in the history
  • Loading branch information
AndrewGable committed Apr 4, 2022
1 parent 3467f88 commit 86050cc
Showing 1 changed file with 11 additions and 14 deletions.
25 changes: 11 additions & 14 deletions src/libs/Navigation/Navigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,16 @@ function dismissModal(shouldOpenDrawer = false) {
}
}

/**
* Returns the current active route
* @returns {String}
*/
function getActiveRoute() {
return navigationRef.current && navigationRef.current.getCurrentRoute().name
? getPathFromState(navigationRef.current.getState(), linkingConfig.config)
: '';
}

/**
* Check whether the passed route is currently Active or not.
*
Expand All @@ -183,20 +193,7 @@ function dismissModal(shouldOpenDrawer = false) {
*/
function isActiveRoute(routePath) {
// We remove First forward slash from the URL before matching
const path = navigationRef.current && navigationRef.current.getCurrentRoute().name
? getPathFromState(navigationRef.current.getState(), linkingConfig.config).substring(1)
: '';
return path === routePath;
}

/**
* Returns the current active route
* @returns {String}
*/
function getActiveRoute() {
return navigationRef.current && navigationRef.current.getCurrentRoute().name
? getPathFromState(navigationRef.current.getState(), linkingConfig.config)
: '';
return getActiveRoute().substring(1) === routePath;
}

/**
Expand Down

0 comments on commit 86050cc

Please sign in to comment.