如何使用 css-in-js 在悬停另一个元素时显示 div 元素?

How to display div element on hover another element using css-in-js?

我试图仅在悬停到特殊 div 时显示一些信息。我正在使用 material ui 及其 withStyles 组件。有办法吗?

请检查这个例子:

import React, {useState} from "react";

export default function ShowButtonHover() {
    const [style, setStyle] = useState({display: 'none'});

    return (
        <div className="App">
            <h2>Hidden message in the box. Move mouse in the box</h2>
            <div style={{border: '1px solid gray', width: 300, height: 300, padding: 10, margin: 100}}
                 onMouseEnter={e => {
                     setStyle({display: 'block'});
                 }}
                 onMouseLeave={e => {
                     setStyle({display: 'none'})
                 }}
            >
                <div style={style}>This was hidden</div>
            </div>
        </div>
    );
}