Reactjs 如何反应我可以通过地图功能外的索引?

Reactjs 如何反应我可以通过地图功能外的索引?,reactjs,function,Reactjs,Function,只是在旋转木马上工作。只是想在按钮结束时禁用它。disabled={index==0}不起作用,因为超出了映射范围。 谢谢你的帮助 <Carousel settings={ settings } ref={ ref }> {slides.map((el, index) => ( <SlideGallery key={ index }> <SlideItems style={{ background: el.imgUrl }}

只是在旋转木马上工作。只是想在按钮结束时禁用它。disabled={index==0}不起作用,因为超出了映射范围。 谢谢你的帮助

<Carousel settings={ settings } ref={ ref }>
    {slides.map((el, index) => (
      <SlideGallery key={ index }>
        <SlideItems style={{ background: el.imgUrl }}>
          <picture><img src={ el.imgUrl } alt=''></img></picture>
          <SlideInner>
            <h3>{el.review}</h3>
            <p></p>
            <p>UserName</p>
          </SlideInner>
        </SlideItems>
      </SlideGallery>
    ))}
  </Carousel>
  <ButtonWrapper>
    <PrevButton onClick={ prevSlide } disabled={ index === 0 }><ChevronLeft/></PrevButton>
    <NextButton onClick={ nextSlide }><ChevronRigt/></NextButton>
  </ButtonWrapper>

{slides.map((el,index)=>(
{el.review}

用户名

))}
您需要将当前幻灯片索引存储在状态中,并使用该状态启用/禁用按钮您的旋转木马开始标记拼写错误。