프로젝트에서 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) –