javascript - 如何避免多次打开模态?
问题描述
我正在尝试将数据发送到我的模态,但是,一旦打开模态,我就会面临一个问题。正如您在图像中看到的那样,它触发了很多次,但是我的模态不是map
我循环以收集从另一个组件发送的信息的功能。
return (
<>
{data.map((data) => { return (
<div className="modal__backdrop">
<div className="modal__container">
<div className="modal-header">
<div className="modal-close" onClick={onRequestClose}>
<svg className='w-6 h-6' fill='none' viewBox='0 0 24 24' stroke='currentColor'>
<path
strokeLinecap='round'
strokeLinejoin='round'
strokeWidth='2'
d='M6 18L18 6M6 6l12 12'/>
</svg>
</div>
</div>
<div className="job-title-wrapper">
<div className="job-card-title">{data.tactic_id}</div>
<div className="job-action">
<svg
className="heart"
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
strokeWidth={2}
strokeLinecap="round"
strokeLinejoin="round">
<path
d="M20.8 4.6a5.5 5.5 0 00-7.7 0l-1.1 1-1-1a5.5 5.5 0 00-7.8 7.8l1 1 7.8 7.8 7.8-7.7 1-1.1a5.5 5.5 0 000-7.8z"/>
</svg>
<svg
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
strokeWidth={2}
strokeLinecap="round"
strokeLinejoin="round"
className="feather feather-share-2">
<circle cx={18} cy={5} r={3}/>
<circle cx={6} cy={12} r={3}/>
<circle cx={18} cy={19} r={3}/>
<path d="M8.6 13.5l6.8 4M15.4 6.5l-6.8 4"/>
</svg>
</div>
</div>
<div className="job-subtitle-wrapper">
<div className="company-name">Patreon
<span className="comp-location">Londontowne, MD.</span>
</div>
<div className="posted">Posted 8 days ago<span className="app-number">98 Application</span>
</div>
</div>
<div className="explain-bar">
<div className="explain-contents">
<div className="explain-title">Experience</div>
<div className="explain-subtitle">Minimum 1 Year</div>
</div>
</div>
<div className="overview-text">
<div className="overview-text-header">Overview</div>
<div className="overview-text-subheader">
We believe that design (and you) will be critical to the company's success. You
</div>
</div>
<div className="overview-text">
<div className="overview-text-header">Job Description</div>
<div className="overview-text-item">3+ years working as a product designer.</div>
</div>
</div>
</div>)
})}
</>
);
};
解决方案
推荐阅读
- fortran - 虚拟调用对 Fortran 程序有影响吗?
- azure - 嵌套 If 语句 Powershell
- flutter - 在表中使用 TextFormField (DataTable)
- javascript - 如何在 Firebase Firestore 中使用多个 orderBy 查询进行排序?
- tensorflow - 无法在 keras 中使用 ImageDataGenerator 获得可重现的结果
- php - 使用 dom outerhtml 时 str_replace 不替换我的 h2 标签
- javascript - 如何将 Angular clientHttp 转换为 node.js
- vapor - Vapor 4:创建包含 Fluent ParentProperty 的协议会导致编译器错误
- php - 表单中的嵌套 href
- javascript - Rails 缺少部分 *.js.erb