carouselRef .getPositionIndex is not a function
See original GitHub issueHi,
App is crashing with message ‘carouselRef .getPositionIndex is not a function’ when clicking on pagination dots
const CarouselPage = ({navigation, ...props}) => {
const [activePage, setActivePage] = useState(0);
useEffect( () => { console.log(' active page : ', activePage) }, [activePage] );
let carouselRef = useRef();
return(
<Carousel
ref={(c) => {carouselRef = c}}
sliderWidth={screenWidth}
sliderHeight={screenWidth}
itemWidth={screenWidth}
data={entries}
renderItem={_renderItem}
onSnapToItem={(index) => { setActivePage(index) }}
/>
<Pagination
dotsLength={entries.length}
activeDotIndex={activePage}
containerStyle={{ backgroundColor: 'rgba(0, 0, 0.6, 0.5)' }}
dotStyle={{
width: 10,
height: 10,
borderRadius: 5,
marginHorizontal: 8,
backgroundColor: 'rgba(255, 255, 255, 0.92)'
}}
inactiveDotStyle={{
// Define styles for inactive dots here
}}
inactiveDotOpacity={0.4}
inactiveDotScale={0.6}
tappableDots={true}
tappableDots={ !!carouselRef }
carouselRef={ carouselRef }
/>
);
};
i am using RN: 0.61.4, react-native-snap-carousel: 3.8.4
can anyone help me in fixing this issue
Issue Analytics
- State:
- Created 4 years ago
- Reactions:4
- Comments:9 (1 by maintainers)
Top Results From Across the Web
carouselRef .getPositionIndex is not a function #626 - GitHub
Hi, App is crashing with message 'carouselRef .getPositionIndex is not a function' when clicking on pagination dots const CarouselPage ...
Read more >javascript - scrollToIndex() is not a function - Stack Overflow
I have currently have a map and a carousel(similar to FlatList ) and I want to be able to use scrollToIndex method of...
Read more >navigation.getParam is not a function (React native) - YouTube
Solve the error message navigation.getParam is not a function @hannan1904 channel using react native Github: ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@venkataluri here is a workaround for you
Same issue here. You can get around it by setting your
carouselRef
to the following:carouselRef={carouselRef.current}
This issue exists because the ref is accessed directly instead of accessing the
current
attribute. When a ref is passed to an element inrender
, a reference to the node becomes accessible at thecurrent
attribute of the ref.I’ll create a pull request as soon as I have some time.