Answer the question
In order to leave comments, you need to log in
How to implement hint when hovering over a block?
There is a react component like this:
<CM.UI.Flexbox.Box className='message-wrapper' column>
<CM.UI.Flexbox.Item flex='0 1 auto'>
{model.get('message')}
</CM.UI.Flexbox.Item>
<CM.UI.Flexbox.Item flex='0 1 auto' style={{opacity: '0.7'}}>
{modelSensor ? `${CM.gettext('Name')}: ${modelSensor.get('description')}` : null}
</CM.UI.Flexbox.Item>
<CM.UI.Flexbox.Item flex='0 1 auto' style={{opacity: '0.7'}}>
{modelSensor && modelSensor.get('location') ? `${CM.gettext('Address')}: ${modelSensor.get('location')}` : null}
</CM.UI.Flexbox.Item>
<CM.UI.Flexbox.Item flex='0 1 auto' style={{opacity: '0.5'}}>
{timeFromNow}
</CM.UI.Flexbox.Item>
</CM.UI.Flexbox.Box>
Answer the question
In order to leave comments, you need to log in
import React, { useState, useCallback } from 'react';
import { Icon, Hint } from '../some-place';
const Example = () => {
const [shouldShowHint, setShouldShowHint] = useState(false);
const onMouseEnter = () => useCallback({
setShouldShowHint(true);
}, []);
const onMouseLeave = useCallback(() => {
setShouldShowHint(false);
}, []);
return (
<div
onMouseEnter={onMouseEnter}
onMouseLeave={onMouseLeave}
>
<Icon />
{shouldShowHint && <Hint />}
</div>
);
};
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question