YIZHUANG / react-multi-carousel

A lightweight production-ready Carousel that rocks supports multiple items and server-side rendering with no dependency. Bundle size 2kb.
MIT License
1.25k stars 286 forks source link

Carousel failed to load items sometimes (containerWidth, itemWidth issue) #266

Closed codex49 closed 2 years ago

codex49 commented 3 years ago

Sometimes the Carousel failed to load items When I check the state in react dev I got 0 in containerWidth and itemWidth, when I change the value of containerWidth to 100 The items loaded, the Carousel works well the the value of containerWidth changes to 1140 and itemWidth to 228

slider

HTML code when the problem is happen <div class="react-multi-carousel-list carouselContainer"><ul class="react-multi-carousel-track " style="transition: none 0s ease 0s; overflow: unset; transform: translate3d(0px, 0px, 0px);"></ul></div>

ankit-kumar-jat commented 2 years ago

i am having same issue if you resolved this issue please comment here

abhinavdalal commented 2 years ago

@ankit-kumar-jat can you confirm that css file is imported via:

import 'react-multi-carousel/lib/styles.css';

zmeyer44 commented 2 years ago

Same issue here

abhinavdalal commented 2 years ago

can someone please share a codesandbox or a js fiddle replicating the issue

ankit-kumar-jat commented 2 years ago

Please check css that you applied and also check css for parent component in which you are using carousel

alicerocheman commented 2 years ago

same issue, if I log my slider's children, it logs children properly, but in the inspector the UL is empty. fragments seem to be wrongly interpreted as well, might be related.

denFete commented 2 years ago

Had the same issue, solved by adding: .react-multi-carousel-list { width: 100%; }

TarikDervisevic commented 2 years ago

I had the same issue and I fixed it by giving the parent div a min-width.

YIZHUANG commented 2 years ago

The parent needs to have a width of 100%