mirror of
https://github.com/zhigang1992/react-navigation.git
synced 2026-02-10 22:47:02 +08:00
fix: don't perform side-effects in setState
This commit is contained in:
@@ -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()}`,
|
||||
|
||||
Reference in New Issue
Block a user