Hello,
I have a problem. I'm trying to use the example of asNavFor REACT-slick but I CAN麓T get synchronize the two sliders, here my code.
thanks in advance for your help
`import React, { Component } from "react";
import ReactDOM from "react-dom";
import PropTypes from "prop-types";
import styled from "styled-components";
import Slider from "react-slick";
import { withI18n } from "../../i18n";
import ReviewItemText from "./ReviewItemText";
import ReviewItemImage from "./ReviewItemImage";
import Title from "../../shared/components/TitleSection";
const Container = styled.div
position: relative;
width: 100%;
margin: 0 auto;
background: white;
text-align: center;
padding-bottom: 100px;
;
const Wrapper = styled.div
overflow: hidden;
position: relative;
width: 80%;
margin: 0 auto;
background: white;
text-align: center;
&:after {
content: "";
position: absolute;
bottom: 0;
right: 0;
width: 30px;
height: 400px;
background: linear-gradient(
to right,
rgba(255, 255, 255, 0),
rgba(255, 255, 255, 1)
);
}
;
const wrapSliderCarouselBottom = styled.div``;
class ReviewList extends Component {
constructor(props) {
super(props);
this.state = {
nav1: null,
nav2: null
};
}
componentDidMount() {
this.setState({
nav1: this.slider1,
nav2: this.slider2
});
}
componentWillUnmount() {}
render() {
const { trans, productName, reviews, product } = this.props;
console.log(this.state);
return (
```
asNavFor={this.state.nav2}
ref={slider => (this.slider1 = slider)}
>
{reviews.map((review, i) => {
return (
);
})}
<div style={{ width: "600px", margin: "auto" }}>
<Slider
className={"slider2"}
asNavFor={this.state.nav1}
ref={slider => (this.slider2 = slider)}
slidesToShow={3}
swipeToSlide={true}
focusOnSelect={true}
>
{reviews.map((review, i) => {
return (
<div key={i}>
<ReviewItemImage
name={review.award.name}
image={review.award.image}
/>
</div>
);
})}
</Slider>
</div>
</div>
</Wrapper>
</Container>
```
);
}
}
export default withI18n(ReviewList);
`
I was trying to figure this out too. The documented way did not work until I manually updated the src.
This is working for me.
Goto this page: https://github.com/akiran/react-slick/issues/1250
Look at how they are implementing sliders first.
Then Importantly, goto
node_modules -> react-slick -> lib -> mixins -> helpers.js
and paste this code located here:
https://github.com/akiran/react-slick/blob/2015e14c03ea0b1728e966ccc12f572453a79fc1/src/mixins/helpers.js
Thank for your help, i solve my issue forcing to install the last version of npm
npm install react-slick@^0.23.1
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Most helpful comment
Thank for your help, i solve my issue forcing to install the last version of npm
npm install react-slick@^0.23.1