【发布时间】:2021-08-12 16:36:47
【问题描述】:
我将 open 一个 prop 传递给一个布尔值的组件
我想添加一个 setTimeout 函数来隐藏组件,但它显示语法错误
Timeout' is not assignable to parameter of type
'Interpolation<ThemedStyledProps<Pick<DetailedHTMLProps<HTMLAttributes<HTMLDivElement>,
HTMLDivElement>, "key" | keyof HTMLAttributes<HTMLDivElement>>
这是我尝试过的
const DrawerContent = styled.div<{ open: boolean; visible?: any }>`
transition: 0.3s all;
${({ open, visible }) =>
open
? css`
display: flex;
width: 200px;
height: 100px;
background-color: brown;
position: absolute;
top: 0;
`
: setTimeout(() => { // i want to add this line
css`
display: none;
`;
}, 200)}
`;
【问题讨论】:
标签: reactjs typescript styled-components