zbtang / React-Native-ViewPager

ViewPager and Indicator component for react-native on both android and ios.
950 stars 276 forks source link

OnPageSelected No overload matches this call. #184

Open dinesh547 opened 4 years ago

dinesh547 commented 4 years ago

I am trying to use the rn-viewpager. But getting a warning on using OnPageSelected Inside <IndicatorViewPager

Code is something like this

<IndicatorViewPager style={{ height: height - (Platform.OS === 'android' ? 50 : 80) }} indicator={this.renderDotIndicator()} onPageSelected={this.getSelectedPage} ref={viewPager => { this.viewPager = viewPager; }}>

//Something here
            </IndicatorViewPager>

Warning appears something like this.

(JSX attribute) onPageSelected: (e: any) => void No overload matches this call. Overload 1 of 2, '(props: Readonly): IndicatorViewPager', gave the following error. Type '{ children: Element[]; style: { height: number; }; indicator: Element; onPageSelected: (e: any) => void; ref: (viewPager: IndicatorViewPager | null) => void; }' is not assignable to type 'IntrinsicAttributes & IntrinsicClassAttributes & Readonly & Readonly<...>'. Property 'onPageSelected' does not exist on type 'IntrinsicAttributes & IntrinsicClassAttributes & Readonly & Readonly<...>'. Overload 2 of 2, '(props: IndicatorViewPagerProps, context?: any): IndicatorViewPager', gave the following error. Type '{ children: Element[]; style: { height: number; }; indicator: Element; onPageSelected: (e: any) => void; ref: (viewPager: IndicatorViewPager | null) => void; }' is not assignable to type 'IntrinsicAttributes & IntrinsicClassAttributes & Readonly & Readonly<...>'. Property 'onPageSelected' does not exist on type 'IntrinsicAttributes & IntrinsicClassAttributes & Readonly & Readonly<...>'.ts(2769)

Do anyone has any fix fo this?