akiran / react-slick

React carousel component
http://react-slick.neostack.com/
MIT License
11.72k stars 2.1k forks source link

AsNavFor doesn't work with version 0.23.0 and higher #1434

Open dideex opened 5 years ago

dideex commented 5 years ago

I have tried to use the code(from here), but it didn't sync well. When i downgrade it to 0.21.0, it works great

import React, { Component } from "react";
import Slider from "react-slick";

export default class AsNavFor extends Component {
  constructor(props) {
    super(props);
    this.state = {
      nav1: null,
      nav2: null
    };
  }

  componentDidMount() {
    this.setState({
      nav1: this.slider1,
      nav2: this.slider2
    });
  }

  render() {
    return (
      <div>
        <h2>Slider Syncing (AsNavFor)</h2>
        <h4>First Slider</h4>
        <Slider
          asNavFor={this.state.nav2}
          ref={slider => (this.slider1 = slider)}
        >
          <div>
            <h3>1</h3>
          </div>
          <div>
            <h3>2</h3>
          </div>
          <div>
            <h3>3</h3>
          </div>
          <div>
            <h3>4</h3>
          </div>
          <div>
            <h3>5</h3>
          </div>
          <div>
            <h3>6</h3>
          </div>
        </Slider>
        <h4>Second Slider</h4>
        <Slider
          asNavFor={this.state.nav1}
          ref={slider => (this.slider2 = slider)}
          slidesToShow={3}
          swipeToSlide={true}
          focusOnSelect={true}
        >
          <div>
            <h3>1</h3>
          </div>
          <div>
            <h3>2</h3>
          </div>
          <div>
            <h3>3</h3>
          </div>
          <div>
            <h3>4</h3>
          </div>
          <div>
            <h3>5</h3>
          </div>
          <div>
            <h3>6</h3>
          </div>
        </Slider>
      </div>
    );
  }
}
Friends-for-Brands commented 5 years ago

I encountered same problem here. I downgraded install to 0.21.0 but still not working. How can I fix it?

ray-su commented 5 years ago

same problem here. Looks like the two sliders only sync once after 2 clicks

ray-su commented 5 years ago

and yes, just downgraded to 0.21.0, and it work perfectly

gracjan-op commented 5 years ago

Yes. version "0.23.1" it's working properly with sync sliders but 0.23.2 it's not. Changing slides every second click.

josaric commented 5 years ago

Yes. version "0.23.1" it's working properly with sync sliders but 0.23.2 it's not. Changing slides every second click.

Tested on 0.23.1, I still have the same problem, slider is skipping every second item. On 0.21.0 work OK.

rus-yurchenko commented 5 years ago

Same here, working correctly only on 0.23.1 version.

jeremylynch commented 5 years ago

Confirming correct behaviour in 0.23.1

escalepion commented 5 years ago

0.23.1 and 0.21.0 didn't work for me. What should i do???

Edit: Ok i figured out that i made a mistake while i was downgrading. After i downgrade to 0.23.1 again,it worked successfully

cMack87 commented 5 years ago

Newest version only syncs every other click.

0.23.1 works for me.