MCPcopy Create free account
hub / github.com/reactstrap/reactstrap / Example

Function Example

stories/examples/Carousel/CustomTagExample.js:28–96  ·  view source on GitHub ↗
(props)

Source from the content-addressed store, hash-verified

26];
27
28function Example(props) {
29 const [activeIndex, setActiveIndex] = useState(0);
30 const [animating, setAnimating] = useState(false);
31
32 const next = () => {
33 if (animating) return;
34 const nextIndex = activeIndex === items.length - 1 ? 0 : activeIndex + 1;
35 setActiveIndex(nextIndex);
36 };
37
38 const previous = () => {
39 if (animating) return;
40 const nextIndex = activeIndex === 0 ? items.length - 1 : activeIndex - 1;
41 setActiveIndex(nextIndex);
42 };
43
44 const goToIndex = (newIndex) => {
45 if (animating) return;
46 setActiveIndex(newIndex);
47 };
48
49 const slides = items.map((item) => {
50 return (
51 <CarouselItem
52 className="custom-tag"
53 tag="div"
54 key={item.id}
55 onExiting={() => setAnimating(true)}
56 onExited={() => setAnimating(false)}
57 >
58 <CarouselCaption
59 className="text-danger"
60 captionText={item.caption}
61 captionHeader={item.caption}
62 />
63 </CarouselItem>
64 );
65 });
66
67 return (
68 <div>
69 <style>
70 {`.custom-tag {
71 max-width: 100%;
72 height: 500px;
73 background: black;
74 }`}
75 </style>
76 <Carousel activeIndex={activeIndex} next={next} previous={previous}>
77 <CarouselIndicators
78 items={items}
79 activeIndex={activeIndex}
80 onClickHandler={goToIndex}
81 />
82 {slides}
83 <CarouselControl
84 direction="prev"
85 directionText="Previous"

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…