react-native-web-swiper icon indicating copy to clipboard operation
react-native-web-swiper copied to clipboard

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

Open pors opened this issue 3 years ago • 3 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.

pors avatar Mar 30 '22 11:03 pors

Add to the index.d.ts

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

eungwang1 avatar Jun 26 '22 12:06 eungwang1

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?

linuxuser07 avatar Jul 07 '22 00:07 linuxuser07

+1 for this feature request

BenStirrup avatar Jul 09 '22 10:07 BenStirrup

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

jarvisluong avatar Oct 02 '22 12:10 jarvisluong