Skip to content

Commit b094769

Browse files
iljadaderkomjackson
authored andcommitted
Allow initialIndex, initialIndex in NativeRouter (#4415)
* Allow initialEntries and initialIndex usage with NativeRouter * Keep initial spacing
1 parent b300c59 commit b094769

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

packages/react-router-native/NativeRouter.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,16 @@ class StoreHistory extends React.Component {
77
router: PropTypes.object.isRequired
88
}
99

10+
static propTypes = {
11+
initialIndex: PropTypes.number,
12+
initialEntries: PropTypes.array
13+
}
14+
15+
static defaultProps = {
16+
initialIndex: 0,
17+
initialEntries: [ '/' ]
18+
}
19+
1020
componentDidMount() {
1121
this.store()
1222
}
@@ -53,8 +63,8 @@ class NativeRouter extends React.Component {
5363
AsyncStorage.getItem('history', (err, history) => {
5464
this.setState({
5565
savedHistory: history ? JSON.parse(history) : {
56-
entries: [ '/' ],
57-
index: 0
66+
entries: this.props.initialEntries,
67+
index: this.props.initialIndex
5868
}
5969
})
6070
})

0 commit comments

Comments
 (0)