style(dashboard-v2): simplify 'key' props

This commit is contained in:
Michał Leszczyk 2022-02-26 12:30:55 +01:00
parent 7adbc4bf68
commit 7681287127
No known key found for this signature in database
GPG Key ID: FA123CA8BAA2FBF4
2 changed files with 10 additions and 9 deletions

View File

@ -9,11 +9,12 @@ export default function Bullets({ visibleSlides, activeIndex, allSlides, changeS
<div className="flex gap-3 pt-6">
{Array(allSlides - visibleSlides + 1)
.fill(null)
.map((_, i) => (
<span
key={`slider-bullets-${i}`}
className={`rounded-full w-3 h-3 ${activeIndex === i ? "bg-primary" : "border-2 cursor-pointer"}`}
onClick={() => changeSlide(i)}
.map((_, index) => (
<button
key={index}
type="button"
className={`rounded-full w-3 h-3 ${activeIndex === index ? "bg-primary" : "border-2 cursor-pointer"}`}
onClick={() => changeSlide(index)}
/>
))}
</div>

View File

@ -55,14 +55,14 @@ const Slider = ({ slides, breakpoints }) => {
$activeIndex={activeIndex}
$scrollable={scrollable}
>
{slides.map((slide, i) => {
const isVisible = i >= activeIndex && i < activeIndex + visibleSlides;
{slides.map((slide, index) => {
const isVisible = index >= activeIndex && index < activeIndex + visibleSlides;
return (
<div key={`slide-${i}`}>
<div key={`slide-${index}`}>
<Slide
isVisible={isVisible || !scrollable}
onClick={scrollable && !isVisible ? () => changeSlide(i) : null}
onClick={scrollable && !isVisible ? () => changeSlide(index) : null}
>
{slide}
</Slide>