Skip to main content

Function: useRegisterEvents()

useRegisterEvents<N, E, G>(): (eventHandlers) => void

React hook that helps you to listen Sigma’s events. It handles for you all the lifecyle of listener (ie. on / remove)

const registerEvents = useRegisterEvents();
const [setHoveredNode,setHoveredNode] = useState<string|null>(null);
...
useEffect(() => {
registerEvents({
enterNode: event => setHoveredNode(event.node),
leaveNode: event => setHoveredNode(null),
});
}, []);

Type Parameters

N extends Attributes = Attributes

E extends Attributes = Attributes

G extends Attributes = Attributes

Returns

Function

Parameters

eventHandlers: Partial<EventHandlers>

Returns

void

Defined in

packages/core/src/hooks/useRegisterEvents.ts:87