I'm using react and I want to make a onMouseOver in order to display a small text
onMouseOver={(e) => { alert('Set to started'); }}
I've tried this action but it makes a HTML alert on top. I just want a small text.
I cant seem to find something that displays it
alertis a function ofwindowobject. Its default behavior is to show a modal that prevent the user from accessing the rest of the program's interface until the dialog box is closed. You can read more here: Window: alert() method.To achieve what you desire, you should create an element, like a
divor apand set styledisplay: noneordisplay: blockfor it, depending on a state, for example[error, setError] = useState('').By the way, with this approach, remember to implement
onMouseLeavealong withonMouseOver, because the state would not automatically reverts to its origin value.Here's a working example for you. Hope it helps.