Skip to content

Commit 38b6aa0

Browse files
(added) hook state to dispatch onhover action object in rect
1 parent 90cf0fb commit 38b6aa0

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/app/components/PerformanceVisx.tsx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React from 'react';
1+
import React, { useState } from 'react';
22
import { BarStack } from '@visx/shape';
33
import { SeriesPoint } from '@visx/shape/lib/types';
44
import { Group } from '@visx/group';
@@ -9,7 +9,9 @@ import { useTooltip, useTooltipInPortal, defaultStyles } from '@visx/tooltip';
99
import { Text } from '@visx/text';
1010
import { schemeSet3 } from 'd3-scale-chromatic';
1111
import snapshots from './snapshots';
12-
import { onHover, onHoverExit } from '../actions/actions'
12+
import { onHover, onHoverExit } from '../actions/actions';
13+
import { useStoreContext } from '../store'
14+
1315

1416
/* NOTES
1517
Issue - Not fully compatible with recoil apps. Reference the recoil-todo-test.
@@ -110,6 +112,8 @@ const getPerfMetrics = (snapshots, snapshotsIds):any[] => {
110112
/* EXPORT COMPONENT */
111113
const PerformanceVisx = (props: BarStackProps) => {
112114

115+
const [{ tabs, currentTab }, dispatch] = useStoreContext();
116+
113117
const { width, height, snapshots, hierarchy } = props;
114118

115119
console.log('snapshots', snapshots);
@@ -215,13 +219,15 @@ const PerformanceVisx = (props: BarStackProps) => {
215219
/* TIP TOOL EVENT HANDLERS */
216220
// Hides tool tip once cursor moves off the current rect
217221
onMouseLeave={() => {
218-
console.log('datafrommouse', data)
222+
// dispatch(onHoverExit(allComponentRtids[bar.key])
219223
tooltipTimeout = window.setTimeout(() => {
220224
hideTooltip();
221225
}, 300);
222226
}}
223227
// Cursor position in window updates position of the tool tip
224228
onMouseMove={event => {
229+
console.log(allComponentRtids[bar.key])
230+
dispatch(onHover(allComponentRtids[bar.key]))
225231
if (tooltipTimeout) clearTimeout(tooltipTimeout);
226232
const top = event.clientY - margin.top - bar.height;
227233
const left = bar.x + bar.width / 2;

0 commit comments

Comments
 (0)