0

I have a snack setup:

https://snack.expo.io/@sj458147/view-not-scrolling

when you click show modal -> Click next button the View horizontally scrolls (animated), which then displays an image carousel. Now when you click an image, the View should horizontally scroll again but I get the error undefined is not an object. The error lies within the file:

SliderEntry.js

select = () => {
this.MyScrollView.current.moveToPage(3);
};

any help resolving the issue would be appreciated. Thanks in advance

Rickin Rathatha
  • 157
  • 1
  • 2
  • 15

2 Answers2

0

You have MyScrollView ref in ShowModal. There are 2 ways:

  • Not recommend: Pass MyScrollView ref as props to Slider, then pass to SliderEntry
  • Recommend: create a callback as props in SliderEntry. Callback to Slider, then callback to ShowModal
tuledev
  • 10,177
  • 4
  • 29
  • 49
0

Pass your function in props to other components and then access these functions from your another component.

You can find the answer here

React : Pass function to child component

Ritviz Sharma
  • 306
  • 1
  • 9