reactrondev / react-native-web-swiper

Swiper-Slider for React-Native and React-Native-Web

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Allow `React.Component`s to be functional components (TypeScript)

pors opened this issue · comments

When using a functional React component for e.g. NextComponent there is a TypeScript mismatch:

No overload matches this call.
  Overload 1 of 2, '(props: SwiperProps | Readonly<SwiperProps>): Swiper', gave the following error.
    Type '() => JSX.Element' is not assignable to type 'ComponentClass<{}, any>'.
      Type '() => Element' provides no match for the signature 'new (props: {}, context?: any): Component<{}, any, any>'.
  Overload 2 of 2, '(props: SwiperProps, context: any): Swiper', gave the following error.
    Type '() => JSX.Element' is not assignable to type 'ComponentClass<{}, any>'.ts(2769)

This TypeScript error disappears when using a class component.

Add to the index.d.ts

export interface SwiperProps { ..., children?: React.ReactNode; }

Add to the index.d.ts

export interface SwiperProps { ..., children?: React.ReactNode; }

which index.d.ts I don't have one on my project.

so create a class component for it, its the best option for now?

+1 for this feature request

Resolved in #84 (released also as v2.2.4)