Skip to content

Commit

Permalink
Merge pull request #4 from arifali123/add-key-prop
Browse files Browse the repository at this point in the history
add key prop in slider to remove warning
  • Loading branch information
jiangbo2015 authored Feb 10, 2022
2 parents caaba92 + 9e59f47 commit e892662
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/carousel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ export const Carousel = ({
}, [index])

React.useEffect(() => {
if(!autoPlay) {
return;
if (!autoPlay) {
return
}
const timer = setInterval(() => handleNext(), interval)
return clearInterval(timer)
Expand All @@ -90,7 +90,7 @@ export const Carousel = ({
return (
<Contaier ref={containerRef}>
{childrens.map((child, i) => (
<Slider onDragEnd={handleEndDrag} x={x} i={i}>
<Slider onDragEnd={handleEndDrag} x={x} i={i} key={i}>
{child}
</Slider>
))}
Expand All @@ -114,7 +114,11 @@ export const Carousel = ({
{renderDots ? (
renderDots({ setActiveIndex: setIndex, activeIndex: index })
) : (
<Dots length={childrens.length} setActiveIndex={setIndex} activeIndex={index} />
<Dots
length={childrens.length}
setActiveIndex={setIndex}
activeIndex={index}
/>
)}
</Contaier>
)
Expand Down

0 comments on commit e892662

Please sign in to comment.