akiran / akiran/react-slick

React - Duplicate slider when i change infinite config

Open
#1,985 0 comments 3 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
11.9k
Forks
2.1k
PR merge metrics
No merged PRs in 30d

Description

Hello everyone, I'm trying to initiate the slider with `infinite: false`, and update the configuration to `infinite: true` of the slider when it is used. I then used the `beforeChange` method to update the value. It works but when the value is modified, for a few seconds the slider is displayed in duplicate.

I'm doing something wrong ?

```
constructor(props) {
super(props);
this.state = {
movies: dataMovies,
infinite: false,
};
}
```

```
render() {
const settings = {
dots: false,
infinite: this.state.infinite,
speed: 500,
slidesToShow: 5,
slidesToScroll: 5,
draggable: false,
beforeChange: (current, next) => this.setState({ infinite: true }),
};

return (



Film en tendance




{this.state.movies.map((movie) => (

))}




);
}
```

![Capture d’écran de 2021-02-08 16-08-39](https://user-images.githubusercontent.com/49270141/107239368-15fc6d00-6a29-11eb-8786-3aeb571cfbad.png)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.