[reactjs] Inline CSS styles in React: how to implement a:hover?

I use a pretty hack-ish solution for this in one of my recent applications that works for my purposes, and I find it quicker than writing custom hover settings functions in vanilla js (though, I recognize, maybe not a best practice in most environments..) So, in case you're still interested, here goes.

I create a parent element just for the sake of holding the inline javascript styles, then a child with a className or id that my css stylesheet will latch onto and write the hover style in my dedicated css file. This works because the more granular child element receives the inline js styles via inheritance, but has its hover styles overridden by the css file.

So basically, my actual css file exists for the sole purpose of holding hover effects, nothing else. This makes it pretty concise and easy to manage, and allows me to do the heavy-lifting in my in-line React component styles.

Here's an example:

_x000D_
_x000D_
const styles = {_x000D_
  container: {_x000D_
    height: '3em',_x000D_
    backgroundColor: 'white',_x000D_
    display: 'flex',_x000D_
    flexDirection: 'row',_x000D_
    alignItems: 'stretch',_x000D_
    justifyContent: 'flex-start',_x000D_
    borderBottom: '1px solid gainsboro',_x000D_
  },_x000D_
  parent: {_x000D_
    display: 'flex',_x000D_
    flex: 1,_x000D_
    flexDirection: 'row',_x000D_
    alignItems: 'stretch',_x000D_
    justifyContent: 'flex-start',_x000D_
    color: 'darkgrey',_x000D_
  },_x000D_
  child: {_x000D_
    width: '6em',_x000D_
    textAlign: 'center',_x000D_
    verticalAlign: 'middle',_x000D_
    lineHeight: '3em',_x000D_
  },_x000D_
};_x000D_
_x000D_
var NavBar = (props) => {_x000D_
  const menuOptions = ['home', 'blog', 'projects', 'about'];_x000D_
_x000D_
  return (_x000D_
    <div style={styles.container}>_x000D_
      <div style={styles.parent}>_x000D_
        {menuOptions.map((page) => <div className={'navBarOption'} style={styles.child} key={page}>{page}</div> )}_x000D_
      </div>_x000D_
    </div>_x000D_
  );_x000D_
};_x000D_
_x000D_
_x000D_
ReactDOM.render(_x000D_
  <NavBar/>,_x000D_
  document.getElementById('app')_x000D_
);
_x000D_
.navBarOption:hover {_x000D_
  color: black;_x000D_
}
_x000D_
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.1.0/react.min.js"></script>_x000D_
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.1.0/react-dom.min.js"></script>_x000D_
_x000D_
<div id="app"></div>
_x000D_
_x000D_
_x000D_

Notice that the "child" inline style does not have a "color" property set. If it did, this would not work because the inline style would take precedence over my stylesheet.