Delay组件
import { useState, useEffect } from 'react'; import PropTypes from 'prop-types'; const Delayed = ({ children, delay }) => { const [isShow, setIsShow] = useState(false); useEffect(() => { setTimeout(() => { setIsShow(true); }, delay); }, [delay]); return isShow ? children : null; }; Delayed.propTypes = { children: PropTypes.node, delay: PropTypes.oneOfType([PropTypes.string, PropTypes.number]), }; export default Delayed;