meliorence / react-native-snap-carousel

Swiper/carousel component for React Native featuring previews, multiple layouts, parallax images, performant handling of huge numbers of items, and more. Compatible with Android & iOS.
BSD 3-Clause "New" or "Revised" License
10.37k stars 2.29k forks source link

Property 'maxToRenderPerBatch' does not exist on type [React-Native + Typescript] #424

Open dopey2 opened 6 years ago

dopey2 commented 6 years ago

Hello, i have a project where i use React-Native + typescript. When I use properties maxToRenderPerBatch or initialNumToRender i have the following error when I compile my ts files into js

 Property 'maxToRenderPerBatch' does not exist on type 'IntrinsicAttributes & IntrinsicClassAttributes<Carousel<Event>> & Readonly<{ children?: ReactNode; }> & Readonly<CarouselProperties<Event>>'

Also these properties doesn't exist in @types/react-native-snap-carousel/index.d.ts

Environment

React: 16.5.0
React native: 0.57.2
react-native-snap-carousel: 3.7.5
typescript: 3.13.
types/react-native-snap-carousel": 3.7.1
birkanu commented 6 years ago

I am running into the same issue. Can someone shed some light on this behavior? @dopey2, have you resolved this?

dopey2 commented 6 years ago

@birkanu , no I didn't solve it

birkanu commented 6 years ago

Bummer, I am hoping someone can reply to this issue soon.

chine commented 4 years ago

It's a band-aid, but you can "fix" this by extending the props interface:

declare module 'react-native-snap-carousel' {
  export interface CarouselProps<T> {
    maxToRenderPerBatch?: number;
  }
}

https://www.typescriptlang.org/docs/handbook/declaration-merging.html

dohooo commented 3 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