React-slick: asNavFor REACT-slick,I CAN麓T get synchronize the two sliders

Created on 30 May 2018  路  3Comments  路  Source: akiran/react-slick

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 (
```


<br /> <div><br /> <Slider<br /> className={"slider1"}<br /> asNavFor={this.state.nav2}<br /> ref={slider => (this.slider1 = slider)}<br /> ><br /> {reviews.map((review, i) => {<br /> return (<br /> <div key={i}><br /> <ReviewItemText text={review.review} /><br /> </div><br /> );<br /> })}<br /> </Slider></p> <pre><code class="prettyprint"> <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> </code></pre> <p>```<br /> );<br /> }<br /> }</p> <p>export default withI18n(ReviewList);<br /> `</p> </div> <div> <span class="badge badge-primary">stale</span> <div class="float-right"> <a class="text-muted" href="https://www.github.com/akiran/react-slick/issues/1250" rel="nofollow noreferrer" target="_blank" onclick="dataLayer.push({'event': 'GAEvent', 'eventCategory': 'click', 'eventAction': 'source_bottom', 'eventLabel': 'Source Bottom', 'eventValue': undefined});">Source</a> </div> </div> </div> <div class="card-footer"> <div class="row"> <div class="col"> <img src="https://avatars.githubusercontent.com/u/32123699?v=4&s=40" style="width:20px; height:20px;" class="mr-2 rounded float-left" alt=" picture"> <strong>enriquelopez-atlas</strong> </div> <div class="col text-right"> </div> </div> </div> </div> </div> <div class="col-12"> <div id="ph-above-best-comment"> </div> </div> <div class="col-12 mb-4 best-comment"> <div> <h2 class="mb-3"><i class="fas fa-check mr-2"></i>Most helpful comment</h2> </div> <div class="card card-custom border-lg-success mb-4"> <div class="card-body pt-3 pb-3 markdown"> <p>Thank for your help, i solve my issue forcing to install the last version of npm </p> <p>npm install react-slick@^0.23.1</p> </div> <div class="card-footer"> <div class="row"> <div class="col"> <img src="https://avatars.githubusercontent.com/u/32123699?v=4&s=40" style="width:20px; height:20px;" class="mr-2 rounded float-left" alt=" picture"> <strong>enriquelopez-atlas</strong> <span class="text-muted ml-1">on 7 Jun 2018</span> </div> <div class="col text-right"> 👍<span class="ml-2 mr-3">4</span> </div> </div> </div> </div> </div> <div class="col-12"> <div class="mb-4"> <ins class="adsbygoogle" style="display:block" data-ad-client="ca-pub-3835332123789605" data-ad-slot="9295564578" data-ad-format="auto" data-full-width-responsive="true"></ins> <script> (adsbygoogle = window.adsbygoogle || []).push({}); </script> </div> </div> <div class="col-12 d-flex align-items-center mb-4"> <h2>All 3 comments</h2> </div> <div class="col-12"> <div class="card card-custom mb-4"> <div class="card-body pt-3 pb-3 markdown"> <p>I was trying to figure this out too. The documented way did not work until I manually updated the src.<br /> This is working for me.<br /> Goto this page: https://github.com/akiran/react-slick/issues/1250<br /> Look at how they are implementing sliders first.<br /> Then Importantly, goto<br /> node_modules -> react-slick -> lib -> mixins -> helpers.js<br /> and paste this code located here:<br /> <a rel="nofollow noopener" target="_blank" href="https://github.com/akiran/react-slick/blob/2015e14c03ea0b1728e966ccc12f572453a79fc1/src/mixins/helpers.js">https://github.com/akiran/react-slick/blob/2015e14c03ea0b1728e966ccc12f572453a79fc1/src/mixins/helpers.js</a></p> </div> <div class="card-footer"> <div class="row"> <div class="col"> <img src="https://avatars.githubusercontent.com/u/10137?v=4&s=40" style="width:20px; height:20px;" class="mr-2 rounded float-left" alt="ghost picture"> <strong>ghost</strong> <span class="text-muted ml-1">on 7 Jun 2018</span> </div> <div class="col text-right"> </div> </div> </div> </div> <div class="card card-custom mb-4"> <div class="card-body pt-3 pb-3 markdown"> <p>Thank for your help, i solve my issue forcing to install the last version of npm </p> <p>npm install react-slick@^0.23.1</p> </div> <div class="card-footer"> <div class="row"> <div class="col"> <img src="https://avatars.githubusercontent.com/u/32123699?v=4&s=40" style="width:20px; height:20px;" class="mr-2 rounded float-left" alt="enriquelopez-atlas picture"> <strong>enriquelopez-atlas</strong> <span class="text-muted ml-1">on 7 Jun 2018</span> </div> <div class="col text-right"> 👍<span class="ml-2 mr-3">4</span> </div> </div> </div> </div> <div class="card card-custom mb-4"> <div class="card-body pt-3 pb-3 markdown"> <p>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.</p> </div> <div class="card-footer"> <div class="row"> <div class="col"> <img src="https://avatars.githubusercontent.com/in/1724?v=4&s=40" style="width:20px; height:20px;" class="mr-2 rounded float-left" alt="stale[bot] picture"> <strong>stale[bot]</strong> <span class="text-muted ml-1">on 2 Jun 2019</span> </div> <div class="col text-right"> </div> </div> </div> </div> </div> <div class="col-12"> <div class="card card-custom mb-4"> <div class="card-body pt-3 pb-3 markdown text-center helpful"> <div class="title">Was this page helpful?</div> <div class="mt-1" onMouseLeave="rating(327780995, 0);"> <i class="fas fa-star inactive" id="star-1" onMouseOver="rating(327780995, 1);" onclick="rate(327780995, 1);"></i> <i class="fas fa-star inactive" id="star-2" onMouseOver="rating(327780995, 2);" onclick="rate(327780995, 2);"></i> <i class="fas fa-star inactive" id="star-3" onMouseOver="rating(327780995, 3);" onclick="rate(327780995, 3);"></i> <i class="fas fa-star inactive" id="star-4" onMouseOver="rating(327780995, 4);" onclick="rate(327780995, 4);"></i> <i class="fas fa-star inactive" id="star-5" onMouseOver="rating(327780995, 5);" onclick="rate(327780995, 5);"></i> </div> <div class="description text-small"><span id="rating-val">0</span> / 5 - <span id="rating-count">0</span> ratings</div> </div> </div> <div class="mb-4"> <ins class="adsbygoogle" style="display:block" data-ad-client="ca-pub-3835332123789605" data-ad-slot="3452512275" data-ad-format="auto" data-full-width-responsive="true"></ins> <script> (adsbygoogle = window.adsbygoogle || []).push({}); </script> </div> </div> </div> </div> <div class="col-12 col-lg-4"> <div id="ph-above-related"></div> <div class="card card-custom issue-box"> <div class="card-body pt-3 pb-5"> <h2 class="mb-4">Related issues</h2> <div> <strong> <a href="/react-slick/119957228/draggable-should-not-move-slides-when-fade-is-on">draggable should not move slides when fade is on</a> </strong> </div> <div class="text-muted text-small mt-2"> <img src="https://avatars.githubusercontent.com/u/2834813?v=4&s=40" style="width:20px; height:20px;" class="mr-2 rounded float-left" alt="darkalor picture"> <strong class="pr-1" dir="ltr">darkalor</strong>  路  <span class="px-1" dir="ltr">4</span><span>Comments</span> </div> <hr /> <div> <strong> <a href="/react-slick/194778741/changing-state-of-parent-component-on-beforechange-callback">Changing state of parent component on "beforeChange" callback breaks carousel</a> </strong> </div> <div class="text-muted text-small mt-2"> <img src="https://avatars.githubusercontent.com/u/4841711?v=4&s=40" style="width:20px; height:20px;" class="mr-2 rounded float-left" alt="nicreichert picture"> <strong class="pr-1" dir="ltr">nicreichert</strong>  路  <span class="px-1" dir="ltr">3</span><span>Comments</span> </div> <hr /> <div> <strong> <a href="/react-slick/433942460/items-display-vertically-and-disappear">Items display vertically and disappear</a> </strong> </div> <div class="text-muted text-small mt-2"> <img src="https://avatars.githubusercontent.com/u/40635633?v=4&s=40" style="width:20px; height:20px;" class="mr-2 rounded float-left" alt="jfamousket picture"> <strong class="pr-1" dir="ltr">jfamousket</strong>  路  <span class="px-1" dir="ltr">3</span><span>Comments</span> </div> <hr /> <div> <strong> <a href="/react-slick/300496155/appendarrows-feature-is-not-implemented-yet">appendArrows feature is not implemented yet</a> </strong> </div> <div class="text-muted text-small mt-2"> <img src="https://avatars.githubusercontent.com/u/8917978?v=4&s=40" style="width:20px; height:20px;" class="mr-2 rounded float-left" alt="laveesingh picture"> <strong class="pr-1" dir="ltr">laveesingh</strong>  路  <span class="px-1" dir="ltr">3</span><span>Comments</span> </div> <hr /> <div> <strong> <a href="/react-slick/317828216/once-react-slick-is-rendered-i-get-cannot-call-a-class-as-a">Once React Slick is rendered I get "Cannot call a class as a function" error</a> </strong> </div> <div class="text-muted text-small mt-2"> <img src="https://avatars.githubusercontent.com/u/15221534?v=4&s=40" style="width:20px; height:20px;" class="mr-2 rounded float-left" alt="BradyEdgar94 picture"> <strong class="pr-1" dir="ltr">BradyEdgar94</strong>  路  <span class="px-1" dir="ltr">3</span><span>Comments</span> </div> </div> </div> <div class="sticky-top pt-4"> <ins class="adsbygoogle" style="display:block" data-ad-client="ca-pub-3835332123789605" data-ad-slot="3919948963" data-ad-format="auto" data-full-width-responsive="true"></ins> <script> (adsbygoogle = window.adsbygoogle || []).push({}); </script> <div id="ph-below-related-2" class="mt-4"> <ins class="adsbygoogle" style="display:block" data-ad-client="ca-pub-3835332123789605" data-ad-slot="3919948963" data-ad-format="auto" data-full-width-responsive="true"></ins> <script> (adsbygoogle = window.adsbygoogle || []).push({}); </script> </div> </div> </div> <div class="col-12 col-lg-4"> </div> </div> <div class="skyscraper-container"> <ins class="adsbygoogle" style="display:block" data-ad-client="ca-pub-3835332123789605" data-ad-slot="7879185320" data-ad-format="vertical" data-full-width-responsive="true"></ins> <script> (adsbygoogle = window.adsbygoogle || []).push({}); </script> </div> </div> <div class="mt-5 spacer"></div> <footer class="mt-5 pb-2 py-4 text-center mt-auto"> <div class="container"> <a class="navbar-brand logo mr-5" href="/"> <img src="/assets/img/logo.svg" width="40" height="40" alt="bleepingcoder logo"> bleeping<strong>coder</strong> </a> <div class="mt-4"> bleepingcoder.com uses publicly licensed GitHub information to provide developers around the world with solutions to their problems. We are not affiliated with GitHub, Inc. or with any developers who use GitHub for their projects. We do not host any of the videos or images on our servers. All rights belong to their respective owners. </div> <div> Source for this page: <a href="https://www.github.com/akiran/react-slick/issues/1250" rel="nofollow noreferrer" target="_blank">Source</a> </div> </div> <hr class="mb-5 mt-5"> <div class="container"> <div class="row"> <div class="col-sm-4 col-lg mb-sm-0 mb-5"> <strong>Popular programming languages</strong> <ul class="list-unstyled mb-0 mt-2"> <li class="mb-2"> <a href="/python" dir="ltr">Python</a> </li> <li class="mb-2"> <a href="/javascript" dir="ltr">JavaScript</a> </li> <li class="mb-2"> <a href="/typescript" dir="ltr">TypeScript</a> </li> <li class="mb-2"> <a href="/cpp" dir="ltr">C++</a> </li> <li class="mb-2"> <a href="/csharp" dir="ltr">C#</a> </li> </ul> </div> <div class="col-sm-4 col-lg mb-sm-0 mb-5"> <strong>Popular GitHub projects</strong> <ul class="list-unstyled mb-0 mt-2"> <li class="mb-2"> <a href="/microsoft/vscode" dir="ltr">vscode</a> </li> <li class="mb-2"> <a href="/numpy/numpy" dir="ltr">numpy</a> </li> <li class="mb-2"> <a href="/ant-design/ant-design" dir="ltr">ant-design</a> </li> <li class="mb-2"> <a href="/mui-org/material-ui" dir="ltr">material-ui</a> </li> <li class="mb-2"> <a href="/vercel/next-js" dir="ltr">next.js</a> </li> </ul> </div> <div class="col-sm-4 col-lg mb-0"> <strong>More GitHub projects</strong> <ul class="list-unstyled mb-0 mt-2"> <li class="mb-2"> <a href="/rust-lang/rust" dir="ltr">rust</a> </li> <li class="mb-2"> <a href="/moment/moment" dir="ltr">moment</a> </li> <li class="mb-2"> <a href="/yarnpkg/yarn" dir="ltr">yarn</a> </li> <li class="mb-2"> <a href="/mozilla/pdf-js" dir="ltr">pdf.js</a> </li> <li class="mb-2"> <a href="/JuliaLang/julia" dir="ltr">julia</a> </li> </ul> </div> </div> </div> <hr class="mb-5 mt-5"> <div class="container text-muted"> 漏 2026 bleepingcoder.com - <a href="/bleeps" rel="nofollow">Contact</a><br /> By using our site, you acknowledge that you have read and understand our <a href="/cookies" rel="nofollow">Cookie Policy</a> and <a href="/privacy" rel="nofollow">Privacy Policy</a>. </div> </footer> <script src="https://code.jquery.com/jquery-3.5.1.slim.min.js" integrity="sha256-4+XzXVhsDmqanXGHaHvgh1gMQKX40OUvDEBTu8JcmNs=" crossorigin="anonymous"></script> <script async src="https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js" integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo" crossorigin="anonymous"></script> <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js" integrity="sha384-wfSDF2E50Y2D1uUdj0O3uMBJnjuUD4Ih7YwaYd1iqfktj0Uod8GCExl3Og8ifwB6" crossorigin="anonymous"></script> <!--<script defer type="text/javascript" src="//s7.addthis.com/js/300/addthis_widget.js#pubid=ra-5fb2db66acbd74b2"></script>--> <script type="text/javascript" src="/assets/js/main.js"></script> <script src="https://cdn.jsdelivr.net/gh/google/code-prettify@master/loader/run_prettify.js"></script></body> </html>