【发布时间】:2019-06-26 18:36:14
【问题描述】:
我正在使用 reactjs,并且我有一个 datepicker 组件,当用户在组件元素之外单击时我会隐藏它。
代码sn-p是这样的:
`
class DatePicker extends Component{
constructor(props){
super(props)
state= { focus: false } // when focus: false i hide the dates component
}
.......
render(){
const { focus } = this.state
return(
<input type="text" placeholder="start date">
<input type="text" placeholder="start date">
{focus && <DatesContainer ...props>} // if focus==false i dont show the <DatesContainer> component.I need to hide it with fade out or something.
)
}
}`
因此,当用户在<DatesContainer/> 之外单击时,state.focus 会更新为 false,重新渲染,这一次,<DatesContainer/> 根本没有渲染,到目前为止一切都很好。但我需要用 0.3 秒的动画来隐藏它。
对此有何看法?
【问题讨论】:
标签: javascript jquery css reactjs