【发布时间】:2021-01-09 05:11:20
【问题描述】:
我无法让 react-spring 工作。我对此很陌生,所以我不知道出了什么问题。我试图让导航栏从上到下显示为 40vh,但它似乎没有识别出传递的道具。我使用了 create-react-app 和 react-spring 8.0.27
App.js:
const App = () => {
const [open, setOpen] = useState(false);
const navprops = useSpring({
from: {height: "0"},
to: {height: "40vh"}
})
return (
<Fragment>
{open ? <Navbar style={navprops}/> : null}
</Fragment>
Navbar.js:
const NavBar = styled(animated.nav)`
width: 100%;
`;
const Navbar = (props) => {
return (
<NavBar style={props.style}>
</NavBar>
);
};
这基本上是代码。还有更多样式道具,但我想这与功能无关。
animated 和 useSpring 被导入到两个文件中进行测试。感谢您的帮助。
【问题讨论】:
标签: javascript reactjs styled-components react-spring