我在某个组件的CSS文件中有一个类,该类会使该组件中的某些元素不可见。我想div
在单击按钮时将其添加到唯一的类,而该按钮恰好在完全不同的组件中。我知道我将如何使用Vanilla javascript做到这一点,但是使用React我一无所知。
我决定使用
CodeSandbox使其更易于签出/编辑:https : //codesandbox.io/s/pedantic-keldysh-yhw2m ? file = / src / components / FaceRecogBox / FaceRecogBox.css PS:在我正在尝试使用LinkedInput.js中的按钮将FaceRecogBox组件添加.vanish
到main-container
div中
您可以执行以下操作:
import React from 'react';
import '../FaceRecogBox/FaceRecogBox.css'
const FaceRecogBox = ({ imageUrl, isDivVisible }) => {
// You should pass the condition as a prop to the FaceRecogBox
return (
<div>
<div className={`main-container ${!isDivVisible && "vanish"}`}>
<div className="brokenlines-container">
<h3>Drag and drop to upload <br/> Or <a href="/">browse</a> this device</h3>
</div>
</div>
<div className="faces">
<img src={imageUrl} alt="" className="faces"/>
</div>
</div>
);
}
export default FaceRecogBox;
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句