Answer the question
In order to leave comments, you need to log in
How to change parent element class when hovering over child?
constructor(){
super();
this.state = {
isHovered: false
};
this.handleHover = this.handleHover.bind(this);
}
handleHover(){
this.setState(prevState => ({
isHovered: !prevState.isHovered
}));
}
render(){
const btnClass = this.state.isHovered ? "pulse" : "";
return (
<div className="РОДИТЕЛЬ"></div>
<div className={btnClass} onMouseEnter={this.handleHover} onMouseLeave={this.handleHover}></div>
)
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question