I am trying to implement vertical carousel using react-native-snap-carousel.What I want to acheive is a vertical carousel with varying carousel height as per the content.As per the documentation of react-native-snap-carousel itemHeight and sliderHeight is required when it comes to vertical carousel. So is there any one that I can achieve itemHeight as per the content size??
Asked
Active
Viewed 592 times
1 Answers
0
As I understand, you want to get the content's view height and give it to the carousel item. You can get position and size properties of items by using their refs.
Firstly, import useRef from react.
import { useRef } from 'react';
After that, create a ref value.
const contentRef = useRef(null);
<View ref={contentRef}> .... </View>
After that, you can get it's properties by
contentRef.nativeEvent.measureInWindow((x, y, width, height) => {
// You can do whatever you want with this data
})

Murat Çelik
- 68
- 9