reactrondev / react-native-web-swiper

Swiper-Slider for React-Native and React-Native-Web
213 stars 56 forks source link

DotComponent type should be ComponentType or FunctionComponent<T> #56

Closed kopax closed 3 years ago

kopax commented 3 years ago

Hi @reactrondev,

Reading https://github.com/reactrondev/react-native-web-swiper/blob/637642e30310c0d267d6f0386ae5612717767761/index.d.ts#L162 it seems that we can't use function component with the ComponentClass type.

Is this a voluntary constraints ? Class are becoming obsolete since react 16

It also seems that the typing is incorrect, while isActive should be in the props, the current typing force us to use Readonly<SwiperProps> which does not include isActive at all.

jarvisluong commented 3 years ago

Will it be better to use React.ReactNode?

kopax commented 3 years ago

TBH, I am just starting with TypeScript. I would personally need to use FunctionComponent<T>, I don't know how it will behave with ReactNode without the tslint from my IDE, otherwise I would have fixed it with my other PR.

kopax commented 3 years ago

Hi @jarvisluong I am still having issue to use a function component because of controlProps, error seems to goes away if I use React.ComponentType<T>, tough I am not sure it's valid.