forked from grafana.jool/grafana-jool
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
19 lines
516 B
19 lines
516 B
import { useEffect, useState } from 'react';
|
|
import useMountedState from 'react-use/lib/useMountedState';
|
|
|
|
export function useHighlight(focusedNodeId?: string) {
|
|
const [highlightId, setHighlightId] = useState<string>();
|
|
const mounted = useMountedState();
|
|
useEffect(() => {
|
|
if (focusedNodeId) {
|
|
setHighlightId(focusedNodeId);
|
|
setTimeout(() => {
|
|
if (mounted()) {
|
|
setHighlightId(undefined);
|
|
}
|
|
}, 500);
|
|
}
|
|
}, [focusedNodeId, mounted]);
|
|
|
|
return highlightId;
|
|
}
|
|
|