我的问题可能不太清楚,但这是我的问题。我使用map方法从数组中获取卡片,并在每个卡片上显示每个项目。我已经触发了“编辑”按钮,以便它会显示隐藏的文本(只想在一个卡片中看到此内容)。但是当我点击一个卡片时,所有卡片都会显示该隐藏消息。你能帮帮我吗?
我想在单击编辑按钮的卡片中看到“只想在一个卡片中看到此内容”文本。
这是我的代码:
我想在单击编辑按钮的卡片中看到“只想在一个卡片中看到此内容”文本。
这是我的代码:
const [edit, setedit]= useState(false)
<Grid container spacing={5} className="main-grid" >
{allitems.map((oneitem, index) => {
return (
<Grid item key={index} md={3} className="itemGrid" >
<Card className="card">
<CardContent>
<Typography className="" color="textSecondary" gutterBottom>
{oneitem.title}
</Typography>/
<p variant="h5" component="h2" className="description">
{oneitem.description}
</p>
<p className="" color="textSecondary">
Created At: {oneitem.createdAt}
</p>
<Button size="small" onClick={()=> deleted(oneitem._id)} >Delete</Button>
<Button size="small" onClick={()=>setedit(!edit)} >Edit</Button> <-here is the problem
{edit && <h1>Want to see this in only one card</h1>}
</CardContent>