我希望每次地图功能迭代时都能更改模态的内容

发布于 2025-01-18 11:10:10 字数 3772 浏览 2 评论 0原文

我想使用地图功能在相同的模态不同的内容上显示并在必要时更新它们,我决定使用道具,我不知道为什么它不起作用。 我得到的是 “此图显示它只是映射的最后一个对象” 当我单击查看全部 ”映射的卡片”

这是我的父组件

<div
      style={{
        display: "flex",
        justifyContent: "space-between",
        fontWeight: 600,
      }}
    >
      {Res.AdmissionsRes.slice(0, 3).map((admission, index) => (
        <S.BackCardGuIn
          bR="16px"
          bg="#f8f9fa"
          bS="0 1px 2px 0 rgb(60 64 67 / 30%), 0 1px 3px 1px rgb(60 64 67 / 15%)"
          style={{ textAlign: "center" }}
          height="32rem"
          width="calc(100% - 190px)"
          padding="0"
          margin="2%"
        >
          <S.BackCardGuInCir
            border="none"
            // bR="20px"
            // bBL="0"
            // bBR="0"
            bPos="center"
            bg={admission.programImg}
            bSize="cover"
            position="relative"
            top="30px"
            width="9rem"
            height="9rem"
          />
          <p
            style={{
              textAlign: "center",
              fontSize: "20px",
              lineHeight: "28px",
              fontWeight: 600,
              marginTop: "35px",
            }}
          >
            {admission.programType}
          </p>
          <p
            style={{
              fontWeight: 500,
              textAlign: "center",
              minHeight: "40px",
            }}
          >
            Accelerate your growth in the medical domain with the fully
            managed RHIBMS school which stands at {admission.programFee}
          </p>
          <div
            style={{
              display: "flex",
              flexDirection: "column",
              justifyContent: "center",
              alignItems: "center",
            }}
          >
            <S.ApplyForThis  onClick={()=> {
              setProgramInstance(admission)
              handleShow();
              }}>
              View All {admission.programType.slice(0, 3)}
            </S.ApplyForThis>
            <Modal
              title={admission.programType}
              programImg={admission.programImg}
              programFee={admission.programFee}
              onClose={() => setShow(false)}
              show={show}
            />

        
      </div>

我的模态组件低于

<E.Modal onLoad={()=>setProgramType(`${props.title}`)} onClick={props.onClose}>
 
  <E.ModalContent
    className="animate__animated animate__bounceInUp"
    onClick={(e) => e.stopPropagation()}
  >
    <E.ModalHeader>
      <E.ModalTitle></E.ModalTitle>
    </E.ModalHeader>
    <E.ModalBody>
    <S.BackCardGuInCir
            border="none"
            // bR="20px"
            // bBL="0"
            // bBR="0"
            bPos="center"
            bg={props.programImg}
            bSize="cover"
            position="relative"
            top="0"
            width="22rem"
            height="22rem"
          />
      <ProgramTable tuition={props.programFee} title={props.title}/>
    </E.ModalBody>
    <E.ModalFooter>
      <E.ModalBtn onClick={props.onClose}>Close!</E.ModalBtn>
    </E.ModalFooter>
  </E.ModalContent>
</E.Modal>

到目前为止,只有最后一个对象始终在模态上呈现而不是更新。我真的被困!

I want to use the map function to show on the same modal different content and update them when necessary, I decided to go with props and I don't get why it isn't working.
What I get instead is This image shows that it maps just the last object
when I click on View All The cards that are mapped

This is my Parent component

<div
      style={{
        display: "flex",
        justifyContent: "space-between",
        fontWeight: 600,
      }}
    >
      {Res.AdmissionsRes.slice(0, 3).map((admission, index) => (
        <S.BackCardGuIn
          bR="16px"
          bg="#f8f9fa"
          bS="0 1px 2px 0 rgb(60 64 67 / 30%), 0 1px 3px 1px rgb(60 64 67 / 15%)"
          style={{ textAlign: "center" }}
          height="32rem"
          width="calc(100% - 190px)"
          padding="0"
          margin="2%"
        >
          <S.BackCardGuInCir
            border="none"
            // bR="20px"
            // bBL="0"
            // bBR="0"
            bPos="center"
            bg={admission.programImg}
            bSize="cover"
            position="relative"
            top="30px"
            width="9rem"
            height="9rem"
          />
          <p
            style={{
              textAlign: "center",
              fontSize: "20px",
              lineHeight: "28px",
              fontWeight: 600,
              marginTop: "35px",
            }}
          >
            {admission.programType}
          </p>
          <p
            style={{
              fontWeight: 500,
              textAlign: "center",
              minHeight: "40px",
            }}
          >
            Accelerate your growth in the medical domain with the fully
            managed RHIBMS school which stands at {admission.programFee}
          </p>
          <div
            style={{
              display: "flex",
              flexDirection: "column",
              justifyContent: "center",
              alignItems: "center",
            }}
          >
            <S.ApplyForThis  onClick={()=> {
              setProgramInstance(admission)
              handleShow();
              }}>
              View All {admission.programType.slice(0, 3)}
            </S.ApplyForThis>
            <Modal
              title={admission.programType}
              programImg={admission.programImg}
              programFee={admission.programFee}
              onClose={() => setShow(false)}
              show={show}
            />

        
      </div>

My Modal component is below

<E.Modal onLoad={()=>setProgramType(`${props.title}`)} onClick={props.onClose}>
 
  <E.ModalContent
    className="animate__animated animate__bounceInUp"
    onClick={(e) => e.stopPropagation()}
  >
    <E.ModalHeader>
      <E.ModalTitle></E.ModalTitle>
    </E.ModalHeader>
    <E.ModalBody>
    <S.BackCardGuInCir
            border="none"
            // bR="20px"
            // bBL="0"
            // bBR="0"
            bPos="center"
            bg={props.programImg}
            bSize="cover"
            position="relative"
            top="0"
            width="22rem"
            height="22rem"
          />
      <ProgramTable tuition={props.programFee} title={props.title}/>
    </E.ModalBody>
    <E.ModalFooter>
      <E.ModalBtn onClick={props.onClose}>Close!</E.ModalBtn>
    </E.ModalFooter>
  </E.ModalContent>
</E.Modal>

So far, only the last object is rendering on the modal always and not updating. I'm really stuck!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文