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

Updating the Slide Index dynamically doesn't work #120

Open
DeborahVdeV opened this issue May 5, 2022 · 0 comments
Open

Updating the Slide Index dynamically doesn't work #120

DeborahVdeV opened this issue May 5, 2022 · 0 comments

Comments

@DeborahVdeV
Copy link

DeborahVdeV commented May 5, 2022

Hi,
I am loving how simple yet efficient this slider is, thank you!
I am however struggling to update the default slide dynamically with the route name (or a prop passed in route), it seems the Slider doesn't get re rendered with the rest of the page. I am using Hooks, and the latest (18.1) version of React

I have tried

  • using a prop to fill the value of SlideIndex
  • using use/setState to return a different number that I call on the SlideIndex Prop,
  • using use/setState to return to return the whole component with a different SlideIndex Prop
  • have the slider as an external component and a nested component.
  • forceUpdate

None of it made any difference (and updating the Props should, to my understanding, have caused a component rerender).

It does work when navigating away to a page with a different component, and then back to a page using the slider Component. Data also updates when displaying text on the page, so the page is refreshing properly.

Nothing seems to work, which leads me to thing the Slider gets created once and doesn't rerender.

Is there a way I could force the instance to recreate, or use a function to set the Slide Index?

Thank you,
Deborah

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

No branches or pull requests

1 participant