source: node_modules/recharts/lib/state/ReportMainChartProps.js@ ba17441

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

Added visualizations

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