To implement boolean state and a function to change the state, you can refer to this code snippet.
function App() {
const [state, setState] = useState(true);
const rotateHandler = () => {
setState(() => !state);
};
return (
<div className="App">
{/* button for changing the state */}
<button onClick={rotateHandler}>Click to rotate and hide</button>
{/* icon for rotation */}
<div>
<FontAwesomeIcon
icon={faAngleRight}
style={{
transform: state ? "rotate(90deg)" : "rotate(0deg)"
}}
/>
</div>
{/* text to be hidden conditionally */}
<div style={{ display: state ? " block" : "none" }}>
<div>This text will be hidden when the state is false</div>
<div>You can click the button</div>
<div>to rotate the arrow icon</div>
<div>and hide this text</div>
</div>
</div>
);
}
You can also add conditions in className rather than inline styles as shown below:
className={state ? "show" : "hide"}