34
loading...
This website collects cookies to deliver better user experience
npm install react-spring
import { useSpring, animated } from 'react-spring'
import { React } from "react";
import { useSpring, animated } from 'react-spring'
import "./App.css"
function App() {
const styles = useSpring({
from: { opacity: "0" },
to: { opacity: "1" },
})
return (
<animated.div className="test" style={styles}></animated.div>
);
}
export default App;
animated.div
. Finally, we add the styles variable to our div using the style={}
property. The styling of the div itself is done separately in our App.css and it is not of much significance. const styles = useSpring({
from: { color: "white" },
to: { color: "cyan" },
config: { duration: "1500" }
})
const styles = useSpring({
from: { opacity: "0" },
to: { opacity: "1" },
config: { duration: "1500" },
loop:true
})
const styles = useSpring({
from: { opacity: "0" },
to: [
{ opacity: "1" },
{ opacity: "0"},
],
config: { duration: "1500" },
loop:true
})
import { React } from "react";
import { useSpring, animated } from 'react-spring'
import "./App.css"
function App() {
const styles = useSpring({
from: { transform: "translateY(0%)" },
to: [
{ transform: "translateY(100%)" },
{ transform: "translateY(0%)"},
],
config: { duration: "1500" },
loop:true
})
return (
<animated.div className="test" style={styles}></animated.div>
);
}
export default App;