Skip to content

Commit

Permalink
Improved destructuring and isInitial assignment
Browse files Browse the repository at this point in the history
  • Loading branch information
ciampo committed Aug 26, 2024
1 parent bfaccad commit 3e6dcbd
Showing 1 changed file with 13 additions and 14 deletions.
27 changes: 13 additions & 14 deletions packages/components/src/navigator/navigator-provider/component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ function goTo(
path: string,
options: NavigateOptions = {}
) {
const { currentLocation, focusSelectors } = state;
const { focusSelectors } = state;
const currentLocation = { ...state.currentLocation, isInitial: false };

const {
// Default assignments
Expand Down Expand Up @@ -120,7 +121,8 @@ function goToParent(
state: RouterState,
options: NavigateToParentOptions = {}
) {
const { currentLocation, screens, focusSelectors } = state;
const { screens, focusSelectors } = state;
const currentLocation = { ...state.currentLocation, isInitial: false };
const currentPath = currentLocation?.path;
if ( currentPath === undefined ) {
return { currentLocation, focusSelectors };
Expand Down Expand Up @@ -154,20 +156,17 @@ function routerReducer(
screens = removeScreen( state, action.screen );
break;
case 'goto':
const goToNewState = goTo( state, action.path, action.options );
currentLocation = {
...goToNewState.currentLocation,
isInitial: false,
};
focusSelectors = goToNewState.focusSelectors;
( { currentLocation, focusSelectors } = goTo(
state,
action.path,
action.options
) );
break;
case 'gotoparent':
const goToParentNewState = goToParent( state, action.options );
currentLocation = {
...goToParentNewState.currentLocation,
isInitial: false,
};
focusSelectors = goToParentNewState.focusSelectors;
( { currentLocation, focusSelectors } = goToParent(
state,
action.options
) );
break;
}

Expand Down

0 comments on commit 3e6dcbd

Please sign in to comment.