Focused index is not persisted when carousel component is re-rendered
See original GitHub issueDescribe the bug Focused index of carousel is not persisted when carousel component is re-rendered.
To Reproduce Steps to reproduce the behavior:
- Render Carousel component with some
data
- Swipe to the second item of carousel
- Rerender Carousel component(in my case it’s update of the data in react-query hook, but could be any reason)
- Focused item is reset to the first one
Expected behavior Focused item should be second item, so the focused item state should persist across the component re-renders, otherwise it’s impossible to update the data, that being rendered by component
Issue Analytics
- State:
- Created a year ago
- Comments:8 (5 by maintainers)
Top Results From Across the Web
React multi carousel renders items wrongly - Stack Overflow
actually this carousel makes a <li> for each element to manoeuvre the carousel effects as you can see in the inspect screenshot.
Read more >ngx-owl-carousel-o - npm
Import CarouselModule into a module which declares a component intended to have a carousel. import { CarouselModule } from 'ngx-owl-carousel-o'; ...
Read more >Building a Smooth Image Carousel with FlatList in React Native
Below, I'm going to show you how to build an image carousel with React Native's <FlatList /> core component. Users will be able...
Read more >lightning-datatable - documentation - Salesforce Developers
This component implements styling from the data tables blueprint in the Salesforce Lightning Design System. lightning-datatable is not supported on mobile ...
Read more >Before After LWC Slider - Salesforce Stack Exchange
Note that I query the component every time not because it is necessary ... and it gets re-rendered somehow, the code might stop...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Uhhhh… You are right. I did some thing wrong with #178. I will fixed it ASAP.
What is the rationale behind such behaviour? I have never experienced it in other carousel packages, focused state is persisted no matter how many re-renders occurred. And this logic may not be compatible with React 18 and concurrent rendering mode where rendering can be stopped/continued at any moment of time.
We can’t use
useRef / useState
for every use-case. For me it’s:const { data } = useQuery(...)
and it could be updated any time.