question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Changing Autoplay via Props Doesn't Work Correctly

See original GitHub issue

Issue Description

With the latest version of React-Slick, 0.14.6, if we update a Carousel’s autoplay property to false the carousel does one more slide before stopping autoplay. Then, if we update the autoplay property again to true the slider’s autoplay functionality no longer works.

Steps to Reproduce

  1. Navigate to this Fiddle (I updated the external react-slick dep to 0.14.6 and added a play/pause button that just updates the autoplay prop in settings).
  2. Observe that autoplay works. There are 4 different images to make this clearer.
  3. Click the pause button. Wait at least an additional 2000ms, and observe that the carousel does one more slide before stopping.
  4. Now click the play button and observe that the carousel’s autoplay doesn’t start up again.

What Causes this bug?

This bug was introduced in https://github.com/akiran/react-slick/pull/526, when autoplay was changed from setInterval to setTimeout.

Fix

I forked the library and fixed this bug. I will submit a PR and reference this issue.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

4reactions
b0000ringcommented, Nov 28, 2017

Still doesn’t work.

0reactions
mrwomskcommented, Oct 10, 2019

It doesn’t work even in 0.25.2

quick hack:

componentDidUpdate(prevProps, prevState) {
    if (!prevState.isAutoplayOn && this.state.isAutoplayOn) {
      this.slider.slickPlay()
    }
  }
setSliderRef = (c) => {
    this.slider = c
  }

<Slider
   ref={this.setSliderRef}
...

idea from https://github.com/akiran/react-slick/pull/651#issuecomment-304287662

Read more comments on GitHub >

github_iconTop Results From Across the Web

reactjs - Video autoplay not working - Trying to find a fix
I have a video background in React. I want it to autoplay. Autoplay does not work. I have ...
Read more >
Video Player Project React - Menu doesn't work
I can't change the video by using the menu buttons. ... ( <div> <video controls autostart autoPlay muted src={this.props.src} /> </div> ); }...
Read more >
Settings - lightGallery
Name Type Default addClass # string "" allowMediaOverlap # boolean false appendCounterTo # string ".lg‑toolbar"
Read more >
Video - Expo Documentation
This page covers video-specific props and APIs. We encourage you to skim through this document to get basic video working, and then move...
Read more >
React.js cheatsheet - Devhints
render () { this.props.fullscreen const { fullscreen, autoplay } = this.props ··· } ... And without constructor using Babel with proposal-class-fields.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found