Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Whenever I updateState, scrolls back to initial tab #128

Closed
yogiben opened this issue Jan 15, 2016 · 7 comments
Closed

Whenever I updateState, scrolls back to initial tab #128

yogiben opened this issue Jan 15, 2016 · 7 comments

Comments

@yogiben
Copy link

yogiben commented Jan 15, 2016

In my small app, whenever I update the state e.g.

this.setState({
      text: text
    })

The tab bar slides back to the original tab.

Running on iOS.

@yogiben yogiben changed the title Whenever I updateState, return to initial tab Whenever I updateState, scrolls back to initial tab Jan 15, 2016
@ghamaide
Copy link

+1

@yogiben
Copy link
Author

yogiben commented Jan 16, 2016

This is a simple example that replicates the error

var Tabs = React.createClass({
  getInitialState() {
    return {
      tab: 0
    }
  },
  handleTabChange(e) {
    this.setState({
      tab: e.i
    })
  },
  render() {
    return (
      <ScrollableTabView onChangeTab={this.handleTabChange}>
        <TestView />
        <TestView />
        <TestView />
      </ScrollableTabView>
    );
  }
})

@yogiben
Copy link
Author

yogiben commented Jan 16, 2016

Debugging package:

Any change in state of the parent element will trigger componentWillReceiveProps

componentWillReceiveProps(props) {
    if (props.initialPage !== this.state.currentPage) {
      this.goToPage(props.initialPage);
    }
  },

This will get check the initialPage prop agains the this.state.currentPage and return to the current page if if doesn't match.

@yogiben
Copy link
Author

yogiben commented Jan 16, 2016

Created PR #129

@skv-headless
Copy link
Collaborator

Please check master version.

@robtg4
Copy link

robtg4 commented Feb 4, 2016

@skv-headless could you go into more detail with your reply? where in master version should we check? How can we solve this?

@skv-headless
Copy link
Collaborator

I use v0.3.5 #129 fixed for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants