i want to make a toggle div by react spring but i got this error (TypeError: Object(...) is not a function)
i want to make a toggle div by react spring but i got this error (TypeError: Object(...) is not a function)
我想通过 React spring 进行切换 div 但我收到此错误(类型错误:对象(...)不是函数)
import React , {useState} from 'react'
import { useSpring ,animated} from 'react-spring/renderprops'
const Togg =()=>{
const [isToggled,setToggle]= useState(false);
const fade = useSpring({
opacity : isToggled ? 1 : 0
});
return(
<div>
<animated.h1 style={fade}>hello</animated.h1>
<button onClick={()=>setToggle(!isToggled)}>Toggle This</button>
</div>
);
}
export default Togg
您的导入语句应该是 import {useSpring, animated} from 'react-spring'
。
我想通过 React spring 进行切换 div 但我收到此错误(类型错误:对象(...)不是函数)
import React , {useState} from 'react'
import { useSpring ,animated} from 'react-spring/renderprops'
const Togg =()=>{
const [isToggled,setToggle]= useState(false);
const fade = useSpring({
opacity : isToggled ? 1 : 0
});
return(
<div>
<animated.h1 style={fade}>hello</animated.h1>
<button onClick={()=>setToggle(!isToggled)}>Toggle This</button>
</div>
);
}
export default Togg
您的导入语句应该是 import {useSpring, animated} from 'react-spring'
。