import React from 'react'; import { makeStyles, Theme, createStyles } from '@material-ui/core/styles'; import Modal from '@material-ui/core/Modal'; import Backdrop from '@material-ui/core/Backdrop'; import { useSpring, animated } from 'react-spring/web.cjs'; // web.cjs is required for IE 11 support const useStyles = makeStyles((theme: Theme) => createStyles({ modal: { display: 'flex', alignItems: 'center', justifyContent: 'center', }, paper: { backgroundColor: theme.palette.background.paper, border: '2px solid #000', boxShadow: theme.shadows[5], padding: theme.spacing(2, 4, 3), }, }), ); interface FadeProps { children?: React.ReactElement; in: boolean; onEnter?: () => {}; onExited?: () => {}; } const Fade = React.forwardRef(function Fade(props, ref) { const { in: open, children, onEnter, onExited, ...other } = props; const style = useSpring({ from: { opacity: 0 }, to: { opacity: open ? 1 : 0 }, onStart: () => { if (open && onEnter) { onEnter(); } }, onRest: () => { if (!open && onExited) { onExited(); } }, }); return ( {children} ); }); export default function SpringModal() { const classes = useStyles(); const [open, setOpen] = React.useState(false); const handleOpen = () => { setOpen(true); }; const handleClose = () => { setOpen(false); }; return (

Spring modal

react-spring animates me.

); }