小编Fir*_*iki的帖子

将 Material-UI 组件与 React-Spring 动画库集成

您可以在这里找到该库: https: //www.react-spring.io/

    import React from "react";
    import ReactDOM from "react-dom";
    import Typography from "@material-ui/core/Typography";
    import { useSpring, animated } from "react-spring";
    
    function App() {
      const props = useSpring({
        opacity: 1,
        from: { opacity: 0 }
      });
      return (
        <div className="App">
          <Typography variant="h2">
            <animated.div style={props}>Example</animated.div>
          </Typography>
    
          {/* UNCOMMENT THE LINE BELOW AND SEE */}
       {/* <animated.Typography variant="h2">Example</animated.Typography> */}
        </div>
      );
    }
    
    const rootElement = document.getElementById("root");
    ReactDOM.render(<App />, rootElement);
Run Code Online (Sandbox Code Playgroud)
**I would love if I could do something like:**

 `<animated.Typography style={`props`}>Example </animated.Typography>` …
Run Code Online (Sandbox Code Playgroud)

reactjs material-ui react-spring

1
推荐指数
1
解决办法
2253
查看次数

标签 统计

material-ui ×1

react-spring ×1

reactjs ×1