Skip to content

Commit a3d17ee

Browse files
authored
Merge pull request ptomasroos#334 from skv-headless/save-childrenusage
save children usage
2 parents 873edc8 + a9765af commit a3d17ee

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

index.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ const ScrollableTabView = React.createClass({
5959
currentPage: this.props.initialPage,
6060
scrollValue: new Animated.Value(this.props.initialPage),
6161
containerWidth: Dimensions.get('window').width,
62-
sceneKeys: this.updateSceneKeys(this.props.children, [], this.props.initialPage),
62+
sceneKeys: this.updateSceneKeys([], this.props.initialPage),
6363
};
6464
},
6565

@@ -87,8 +87,8 @@ const ScrollableTabView = React.createClass({
8787
}
8888
}
8989

90-
if (this.props.children.length !== this.state.sceneKeys.length) {
91-
let newKeys = this.updateSceneKeys(this.props.children, this.state.sceneKeys, pageNumber);
90+
if (this._children().length !== this.state.sceneKeys.length) {
91+
let newKeys = this.updateSceneKeys(this.state.sceneKeys, pageNumber);
9292
this.setState({currentPage: pageNumber, sceneKeys: newKeys, });
9393
} else {
9494
this.setState({currentPage: pageNumber, });
@@ -105,9 +105,9 @@ const ScrollableTabView = React.createClass({
105105
}
106106
},
107107

108-
updateSceneKeys(children, sceneKeys = [], currentPage) {
108+
updateSceneKeys(sceneKeys = [], currentPage) {
109109
let newKeys = [];
110-
children.forEach((child, idx) => {
110+
this._children().forEach((child, idx) => {
111111
let key = this._makeSceneKey(child, idx);
112112
if (this._keyExists(sceneKeys, key) || currentPage === idx) {
113113
newKeys.push(key);
@@ -202,8 +202,8 @@ const ScrollableTabView = React.createClass({
202202
localCurrentPage = currentPage.nativeEvent.position;
203203
}
204204
// scenekeys length and children length is same then no need to update the keys as all are stored by now
205-
if (this.props.children.length !== this.state.sceneKeys.length) {
206-
let newKeys = this.updateSceneKeys(this.props.children, this.state.sceneKeys, localCurrentPage);
205+
if (this._children().length !== this.state.sceneKeys.length) {
206+
let newKeys = this.updateSceneKeys(this.state.sceneKeys, localCurrentPage);
207207
this.setState({currentPage: localCurrentPage, sceneKeys: newKeys, }, () => {
208208
this.props.onChangeTab({ i: localCurrentPage, ref: this._children()[localCurrentPage], });
209209
});

0 commit comments

Comments
 (0)