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
Carousel has implicit and undocumented expectations on its children #1328
Comments
Your link is broke 👎 |
@xavierartot the Stackblitz? It works for me™. It contains the same code as I posted above, so it's not strictly needed to reproduce the error. |
I see the same thing. In fact, Carousel throws an error in any situation in which it doesn't have direct CarouselItem children. Even if it's because there's a custom component between Carousel and CarouselItem that doesn't render anything. |
IMHO Carousel should be rewritten/refactored. Several things need to be addressed; the easy of use of being the main one. |
Something else that needs to be addressed: if I have a Carousel with 2 items, and I have |
It also appears the error <Carousel>
<CarouselItem />
</Carousel> |
if your images data array is empty, just add an empty array like below. const items = Refer the complete code:-
|
Carousel
6.5.0
es
16.6.3
4.1.3
What is happening?
The API for the
Carousel
has implicit and undocumented expectations on itschildren
:CarouselIndicators
and individualCarouselItem
elements.I also don't understand why
CarouselIndicators
takes an array of items instead of a count (or does not just get this injected from the wrappingCarousel
component).What should be happening?
It should be possible to render a
Carousel
withCarouselIndicators
and singleCarouselItem
followed by a list ofCarouselItem
components. Also it should be possible to render theCarousel
without any children (useful if these are fetched from a remote source).Steps to reproduce issue
Carousel
without anychildren
.or
Carousel
with aCarouselIndicators
and singleCarouselItem
followed by an array ofCarouselItem
components.Error message in console
Code
https://stackblitz.com/edit/reactstrap-cmtxoq?file=Example.js
The text was updated successfully, but these errors were encountered: