I have a banner my React component, to which I want to add "dismiss" capability. The current implementation looks like:
function Home() {
return(
<Banner />
<Main />
);
}
function Banner() {
const [hide, setHide] = React.useState(false);
const handleClick = () => setHide(true);
return !hide ? (
<div>
This is a banner.
<button onClick={handleClick}>Dismiss</button>
</div> : null;
}
However, this implementation is rather abrupt and I can't animate it. Is there a better way to avoid jumping of the elements to provide a better UI?