for some reason onSlideClick (callback) is returning the right result on the second click ... when I replaced the spread operator with push() it worked. why does this function adds index to slidesIndex only in the second click ?
handleClick = (index) => {
const { onSlideClick } = this.props
const { slidesIndex } = this.state
if (!slidesIndex.includes(slidesIndex[index])) {
this.setState({
slidesIndex: [...slidesIndex, index]
})
console.log('add')
}
onSlideClick(slidesIndex)
}