import React, { useEffect, useRef, useState } from 'react'; import Box from '@mui/material/Box'; import useMediaQuery from '@mui/material/useMediaQuery'; import { SxProps, useTheme } from '@mui/material/styles'; import './Beta.css'; type BetaProps = { adaptive?: boolean; onClick?: (event?: React.MouseEvent) => void; sx?: SxProps; }; const Beta: React.FC = (props: BetaProps) => { const { onClick, adaptive = true, sx = {} } = props; const betaRef = useRef(null); const theme = useTheme(); const isMobile = useMediaQuery(theme.breakpoints.down('md')); const [animationKey, setAnimationKey] = useState(0); const [firstPass, setFirstPass] = useState(true); useEffect(() => { // Initial animation trigger if (firstPass && betaRef.current) { triggerAnimation(); setFirstPass(false); } }, [firstPass]); const triggerAnimation = (): void => { if (!betaRef.current) return; // Increment animation key to force React to recreate the element setAnimationKey(prevKey => prevKey + 1); // Ensure the animate class is present betaRef.current.classList.add('animate'); }; return ( { onClick && onClick(e); }} > BETA ); }; export { Beta };