Scenario: When using the Carousel component of antd, customize the left and right switch buttons, and an error will be reported when the next() and prev() methods of the component are triggered
Wrong wording:
handleNext(){
this.refs.img.next()
}
<Carousel
dots={
false}
ref="img"
>
...
</Carousel>
handleNext is my custom button to switch the next picture method, get the Carousel component instance through refs, and call the next() method of the Carousel component
报错截图:
Property ‘next’ does not exist on type ‘Component<any, {}, any>’
solution:
handleNext(){
(this.refs.img as any).next();
}