you need to use React.createRef() in your constructor. And use this reference in your component. In go() function, to achieve moveToPage(2) you need to use current of your reference like in the below;
class ShowModal2 extends Component {
constructor(props){
super(props);
this.MyScrollView = React.createRef();
}
go = () => {
this.MyScrollView.current.moveToPage(2);
};
render() {
return (
<Modal
style={styles.modal}
isVisible={true}
onBackdropPress={this.hideModal}>
<MyScrollView ref={this.MyScrollView}>
......
and apply same approach to other class
class MyScrollView extends Component {
constructor() {
super();
this.state = { page: '' }
this.scrollView = React.createRef();
}
moveToPage(page) {
this.scrollView.current.scrollTo({ x: ((page - 1) * device_width), y: 0,
animated: true });
alert(page);
}
render() {
return (
<View style={styles.container}>
<ScrollView ref={this.scrollView} showsHorizontalScrollIndicator={false} horizontal={true} pagingEnabled={true}>
......
and check from link please-> https://snack.expo.io/@sdkcy/stackoverflow-unable-to-call-method