source: node_modules/recharts/es6/state/ReportMainChartProps.js

Last change on this file was a762898, checked in by istevanoska <ilinastevanoska@…>, 5 months ago

Added visualizations

  • Property mode set to 100644
File size: 1.3 KB
Line 
1import { memo, useEffect } from 'react';
2import { useIsPanorama } from '../context/PanoramaContext';
3import { setLayout, setMargin } from './layoutSlice';
4import { useAppDispatch } from './hooks';
5import { propsAreEqual } from '../util/propsAreEqual';
6
7/**
8 * "Main" props are props that are only accepted on the main chart,
9 * as opposed to the small panorama chart inside a Brush.
10 */
11
12function ReportMainChartPropsImpl(_ref) {
13 var {
14 layout,
15 margin
16 } = _ref;
17 var dispatch = useAppDispatch();
18
19 /*
20 * Skip dispatching properties in panorama chart for two reasons:
21 * 1. The root chart should be deciding on these properties, and
22 * 2. Brush reads these properties from redux store, and so they must remain stable
23 * to avoid circular dependency and infinite re-rendering.
24 */
25 var isPanorama = useIsPanorama();
26 /*
27 * useEffect here is required to avoid the "Cannot update a component while rendering a different component" error.
28 * https://github.com/facebook/react/issues/18178
29 *
30 * Reported in https://github.com/recharts/recharts/issues/5514
31 */
32 useEffect(() => {
33 if (!isPanorama) {
34 dispatch(setLayout(layout));
35 dispatch(setMargin(margin));
36 }
37 }, [dispatch, isPanorama, layout, margin]);
38 return null;
39}
40export var ReportMainChartProps = /*#__PURE__*/memo(ReportMainChartPropsImpl, propsAreEqual);
Note: See TracBrowser for help on using the repository browser.