|
1 | 1 | // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. |
2 | 2 | // SPDX-License-Identifier: Apache-2.0 |
3 | | -import React, { useImperativeHandle, useRef, useState } from 'react'; |
| 3 | +import React, { useImperativeHandle, useLayoutEffect, useRef, useState } from 'react'; |
4 | 4 | import { fireEvent, render } from '@testing-library/react'; |
5 | 5 |
|
6 | 6 | import { ElementWrapper } from '@cloudscape-design/test-utils-core/dom'; |
7 | 7 | import { KeyCode } from '@cloudscape-design/test-utils-core/utils'; |
8 | 8 |
|
9 | | -import { useReaction } from '../../../lib/components/area-chart/async-store'; |
10 | 9 | import { AreaChartProps } from '../../../lib/components/area-chart/interfaces'; |
11 | 10 | import { ChartModel } from '../../../lib/components/area-chart/model'; |
12 | 11 | import useChartModel, { UseChartModelProps } from '../../../lib/components/area-chart/model/use-chart-model'; |
@@ -60,8 +59,8 @@ function RenderChartModelHook(props: UseChartModelProps<ChartDataTypes>) { |
60 | 59 | popoverRef, |
61 | 60 | }); |
62 | 61 |
|
63 | | - useReaction(interactions, state => state.highlightedPoint, setHighlightedPoint); |
64 | | - useReaction(interactions, state => state.highlightedX, setHighlightedX); |
| 62 | + useLayoutEffect(() => interactions.subscribe(s => s.highlightedPoint, setHighlightedPoint), [interactions]); |
| 63 | + useLayoutEffect(() => interactions.subscribe(s => s.highlightedX, setHighlightedX), [interactions]); |
65 | 64 |
|
66 | 65 | useImperativeHandle(refs.plot, () => ({ |
67 | 66 | svg: svgRef.current!, |
|
0 commit comments