1. import React, { useState } from 'react';
    2. import { useTransition, animated } from 'react-spring';
    3. function App() {
    4. const [show, set] = useState(false)
    5. const [items, setItems] = useState([{text:'zhangsan',key:1},
    6. {text:'lisi',key:2},{text:'wangwu',key:3}])
    7. const transitions = useTransition(show, {
    8. from: { opacity: 0 },
    9. enter: { opacity: 1 },
    10. leave: { opacity: 0 },
    11. reverse: show,
    12. delay: 300,
    13. // config: config.molasses,
    14. // onRest: () => set(!show),
    15. })
    16. return (
    17. <div>
    18. {
    19. transitions(
    20. (styles, item) => item && <animated.div style={styles}>✌️</animated.div>
    21. )
    22. }
    23. <button onClick={() => set(true)}>asdf</button>
    24. </div>
    25. )
    26. }
    27. export default App;