Allow `React.Component`s to be functional components (TypeScript)
pors opened this issue · 4 comments
pors commented
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.
eungwang1 commented
Add to the index.d.ts
export interface SwiperProps { ..., children?: React.ReactNode; }
linuxuser07 commented
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?
BenStirrup commented
+1 for this feature request
jarvisluong commented
Resolved in #84 (released also as v2.2.4)