I want to create a button whose styling changes on a hover and stays that way until another hover occurs. Essentially, I want to create a button whose focus is changed by a hover, as seen here. I think I can do this with some functions changing the state between the parent and child, but is there a more simple way of doing this? Thanks.
class Button extends React.Component {
render() {
return (
<button>{this.props.title}</button>
);
}
}
class Parent extends React.Component {
render() {
return (
<div>
<Button title={"button 1"}/>
<Button title={"button 2"}/>
<Button title={"button 3"}/>
</div>
);
}
}
ReactDOM.render(<Parent />, app);
button:hover {
background-color: yellow;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.1.0/react.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.1.0/react-dom.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="app"></div>