react中使用element-react轮播图插件,简单的页面使用了路由切换页面,首页有轮播图,其他也没有轮播图,在切换的时候就会报出内存泄漏,个人认为是因为轮播图的定时器在组件销毁的时候没有被清除导致。但是因为使用的是插件,不知道定时器名字,有没有办法在componentWillUnMount的时候清除这个定时器呢?
附上简单的轮播图组件:
class Banner extends Component {
componentWillUnmount(){
}
render(){
return(
<div className="banner">
<Carousel indicatorPosition="outside">
{
this.props.imgs.map((item, index) => {
return (
<Carousel.Item key={index}>
<img src={item.url} alt={item.title}/>
</Carousel.Item>
)
})
}
</Carousel>
</div>
)
}
};