90
rated 0 times
[
97]
[
7]
/ answers: 1 / hits: 60692
/ 7 Years ago, wed, january 25, 2017, 12:00:00
I have a Basket
component which needs to toggle a BasketContents
component when clicked on. This works:
constructor() {
super();
this.state = {
open: false
}
this.handleDropDown = this.handleDropDown.bind(this);
}
handleDropDown() {
this.setState({ open: !this.state.open })
}
render() {
return(
<div className=basket>
<button className=basketBtn onClick={this.handleDropDown}>
Open
</button>
{
this.state.open
?
<BasketContents />
: null
}
</div>
)
}
It uses a conditional to either display the BasketContents
component or not. I now want it to fade in. I tried adding a ComponentDidMount
hook to BasketContents
to transition the opacity but that doesn't work. Is there a simple way to do this?
More From » css