Ricardo Alejandre Ricardo Alejandre - 9 months ago 292
Android Question

React-Native .scrollTo with InteractionManager not working

I'm trying to get the initial position of the app at x:(device.width*2) since the app consist of 3 main views, yet it doesn't seem to move even with the animation delay, it start on the left view.

componentDidMount() {
const offset = window.width * this.props.initialIndex;
InteractionManager.runAfterInteractions(() => {
this._scrollView.scrollTo({x:offset, animated: false});

Answer Source

I also tried with Interaction Manager, but i don't know why it doesn't work; setting a timeout worked for me.

setTimeout(() => {
    this.scrollView.scrollTo(cordenates, animated);
}, 0);