Open kickbk opened 4 years ago
Sorry, please allow me to advertise for my open source library! ~ I think this library react-native-reanimated-carousel will solve your problem. It is a high performance and very simple component, complete with React-Native reanimated 2
Having same issues.
Still having issues in 2024
The Documentation needs to use Typecript and functional component.
I also encountered the similar error when wrapping a functional component with memo, but the following method worked for me.
type Item = {
id: number
text: string
}
const ITEMS: Item[] = [
...
]
type Props = { item: Item; index: number };
const Item = memo(({ item }: Props) => {
return <Text>id: {item.id}, title: {item.title}</Text>
});
...
<Carousel
layout="default"
data={ITEMS}
renderItem={(props: ItemProps) => <Item {...props} />}
...
/>
Really love this snap carousel. I'm having an issue where I get TypeScript error on
renderItem
.I am importing
meals
, which is aMeal[]
that cannot contain unknown objects. When I hover on top ofitem
in the render function, I can see the item is of typeMeal
.The full error I am getting is:
However, if I simple render a snap carousel using an simple array of items from a local file, then I don't get this error.
What am I doing wrong?
I should also mention that when I run
tsc
I am getting an error for the typescript definition file of the library as well and forrenderItem
as well: