I am using the Ant Design Carousel component in React & TypeScript. The Carousel component has the methods "next" and "prev" on it.
The code runs, however TSLint is highlighting "carousel" and throwing this error "Property 'carousel' does not exist on type 'StyledCarousel'.ts(2339)". Is there some typing declaration I am missing?
Ant Design Docs Here
import React from 'react';
import { Carousel, Icon } from 'antd';
class StyledCarousel extends React.Component {
constructor(props: any) {
super(props);
this.state = {};
this.next = this.next.bind(this);
this.previous = this.previous.bind(this);
this.carousel = React.createRef();
}
public next = () => {
this.carousel.next();
};
public previous = () => {
this.carousel.prev();
};
public render() {
const props = {
dots: true,
infinite: true,
speed: 500,
slidesToShow: 1,
slidesToScroll: 1,
};
return (
<div>
<Icon type="left-circle" onClick={this.previous} />
<Carousel ref={node => (this.carousel = node)} {...props}>
<h1>Item 1</h1>
<h1>Item 2</h1>
<h1>Item 3</h1>
</Carousel>
<Icon type="right-circle" onClick={this.next} />
</div>
);
}
}
export default StyledCarousel;