私はReact Nativeのプロジェクトで作業しています。私はScrollView
の位置を設定したいと思います。だから私は検索して、私たちはscrollTo
でこれを行うべきで見つかりましたが、私はエラーがあります:私はscrollToを使用します
TypeError: Cannot read property 'scrollTo' of undefined
マイコード:
export default class Index_calendar extends Component {
componentDidMount() {
const _scrollView = this.scrollView;
_scrollView.scrollTo({x: 100});
}
render() {
return (
<ScrollView ref={scrollView => this.scrollView = scrollView}>
{this.renderCalandar()}
</ScrollView>
);
}
}
https://github.com/malte-wessel/react-custom-scrollbars/issues/196がうまくいけば、これは便利です – Aaqib
'scrollTo'は、[ウィンドウAPI]の一部です(https://で開発。 mozilla.org/en-US/docs/Web/API/Window/scrollTo) –