fix: don't perform side-effects in setState

This commit is contained in:
satyajit.happy
2019-06-10 15:47:01 +02:00
parent 33fd99c842
commit 67b09da633
6 changed files with 109 additions and 54 deletions

View File

@@ -7,6 +7,7 @@ import {
NavigationState,
NavigationProp,
CommonAction,
InitialState,
} from '../src/index';
type Props = {
@@ -31,12 +32,11 @@ const StackRouter = {
}: {
routeNames: string[];
initialRouteName?: string;
}): NavigationState {
}): InitialState {
const index = routeNames.indexOf(initialRouteName);
return {
index,
names: routeNames,
routes: routeNames.slice(0, index + 1).map(name => ({
name,
key: `${name}-${shortid()}`,