【发布时间】:2022-11-28 23:08:15
【问题描述】:
const [isHovering, setIsHovering] = useState({box1: false, box2: false, box3: false, box4: false});
const handleMouseOver = (e,box_id) => {
setIsHovering({box_id: true});
};
const handleMouseOut = (e,box_id) => {
setIsHovering({box_id: false});
};
return (
<div className="service_body_element">
<div className="service_body_el" onClick={ (e) => handleMouseOver(e, "box1") }>
<img src="" alt=""
className="service_body_el_img"/>
<h3 className="service_body_el_title">Business<br/>Advisory</h3>
</div>
</div>
)
我如何获得“box_id”道具,以通过 setIsHovering 更改状态? 反应项目
【问题讨论】:
标签: reactjs react-hooks react-props