animation presence transition when exit time
const MagicComponent = () => {
2
const [hidden, setHidden] = React.useState(false);
3
4
return (
5
<AnimatePresence>
6
{!hidden && (
7
<motion.button
8
initial={{ opacity: 1 }}
9
exit={{ opacity: 0 }}
10
onClick={() => setHidden(true)}
11
>
12
Click to hide
13
</motion.button>
14
)}
15
</AnimatePresence>
16
);
17
};