What would be the best way to handle multiple buttons that show/hide their respective DIVs.
Example of the Code I have below. As you can see it's set to handle just the first button. I need a method to continually add more buttons that show/hide their own DIVs.
Example: When Button(A) is clicked DIV(A) fades in. If Button(A) is clicked again DIV(A) fades out. If/instead Button(B) is clicked and DIV(A) is visible, then DIV(A) fades out and DIV(B) fades in. so on.. etc..
const Example2: React.FC = () => {
const [style, setStyle] = useState("invis");
const changeStyle = () => {
console.log("you just clicked");
setStyle("vis");
};
return (
<Container className="content">
<section className="section">
<div className="video_section">
<video src={videoUrl} width="" height ="" loop autoPlay muted> </video>
<div className="video_words">
<p><span>Video Words</span></p>
<h1>
<span>V</span>
<span>I</span>
<span>D</span>
<span>E</span>
<span>O</span>
</h1>
<div className="TierTwo">
<div className="Top1">
<button type="button" onClick={changeStyle} className="Lrow1">
<img src="/img/image1.png" height="auto" width="auto" />
</button>
<div className={style}>
<One />
</div>
<div className={style}>
<Two />
</div>
<div className="Rrow1">
<button type="button" onClick={changeStyle} className="Rrow1">
<img src="/img/image2.png" height="auto" width="auto" />
</button>
</div>
</div>
<div className="Top2">
<button type="button" onClick={changeStyle} className="Lrow2">
<img src="/img/image3.png" height="auto" width="auto" />
</button>
<div className={style}>
<Three />
</div>
<div className={style}>
<Four />
</div>
<div className="Rrow1">
<button type="button" onClick={changeStyle} className="Rrow2">
<img src="/img/image4.png" height="auto" width="auto" />
</button>
</div>
</div>
<div className="Top2">
..etc..