What is the best way to hide or show a div (or whatever element) on a state change.
Here is what I did:
React.useEffect(()=>{
(async () => {
alert(props.changeVisibiltyEvent)
})()
},[props.changeVisibiltyEvent])
This effect is called whenever something else happens in my app. The alert displays a 0 or a 1.
If it is zero, the element should be invisible, if it is one, I want it to become visible. Easy.
This is the element:
<td style={{ visibility: 'hidden' }}>
<Button variant="contained" onClick={() => changeCase('closeCase')}>fall schließen</Button>
</td>
I managed to find the attribute 'hidden' to hide it and 'visible' to show it.
What is the best practice to bind the state changed 0 or 1 to visible to hidden in the element?