I have a Basket component that needs to switch the BasketContents component when clicked. It 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 expression to display the BasketContents component or not. Now I want it to fade. I tried adding a ComponentDidMount hook to BasketContents to block the opacity, but this will not work. Is there an easy way to do this?
source share