Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

playDirection change within HoC isn't reflecting in the carousel #170

Open
mccp93 opened this issue Sep 4, 2019 · 1 comment
Open

playDirection change within HoC isn't reflecting in the carousel #170

mccp93 opened this issue Sep 4, 2019 · 1 comment

Comments

@mccp93
Copy link

mccp93 commented Sep 4, 2019

Hey there,

I'm trying to use the HoC wrapper to determine when a carousel reaches the end of it's total slides, then reversing the playDirection via the setStoreState method - however despite reflecting in the props that the value has been changed to backward - the carousel still continues to play in the forward direction.

If I manually input an event such as a click on NextButton, PrevButton or a Dot the carousel then reflects the change. What's strange is properties such as isPlaying or currentSlide reflect immediately but for some reason playDirection does not.

Some example code.

class NavigationControl extends React.Component {

  componentDidUpdate() {
    if (this.props.currentSlide === 5) {
      this.props.carouselStore.setStoreState({ playDirection: "backward" });
    }
  }

 render() {
    // render stuff here
 }
}

export default WithStore(NavigationControl, state => ({
  currentSlide: state.currentSlide,
  playDirection: state.playDirection,
  totalSlides: state.totalSlides
}));

My NavigationControl component is within the CarouselProvider as shown within the documentation.

Any ideas?
If I am approaching this the wrong way or there is a simpler solution then I would be very grateful for the guidance 😄

Thanks,
Paul

@mrbinky3000 mrbinky3000 added the bug label Sep 5, 2019
@mrbinky3000 mrbinky3000 self-assigned this Sep 5, 2019
@mrbinky3000
Copy link
Collaborator

You found a bug! Working on a fix now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants