Skip to content

Commit 07cca9c

Browse files
committed
add navigateAndReset service
1 parent 107b114 commit 07cca9c

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

App/Sagas/StartupSaga.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,5 @@ export function* startup() {
1212
// Do operation here :
1313
// ...
1414
// When operations are finished redirect to InitialPage
15-
NavigationService.navigate('InitialPage')
15+
NavigationService.navigateAndReset('InitialPage')
1616
}

App/Services/NavigationService.js

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { NavigationActions } from 'react-navigation'
1+
import { NavigationActions, StackActions } from 'react-navigation'
22

33
let _navigator
44

@@ -15,9 +15,24 @@ function navigate(routeName, params) {
1515
)
1616
}
1717

18-
// add other navigation functions that you need and export them
18+
function navigateAndReset(routeName, params) {
19+
_navigator.dispatch(
20+
StackActions.reset({
21+
index: 0,
22+
key: null,
23+
actions: [
24+
NavigationActions.navigate({
25+
routeName,
26+
params,
27+
}),
28+
],
29+
})
30+
)
31+
}
1932

33+
// add other navigation functions that you need and export them
2034
export default {
2135
navigate,
36+
navigateAndReset,
2237
setTopLevelNavigator,
2338
}

0 commit comments

Comments
 (0)