victory-stack 36.8.1 → 36.8.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- export declare function getCalculatedProps(props: any, childComponents: any): {
1
+ export declare function getCalculatedProps(initialProps: any, childComponents: any): {
2
2
  datasets: any;
3
3
  categories: any;
4
4
  range: any;
@@ -49,5 +49,5 @@ export declare function getChildProps(props: any, calculatedProps: any): {
49
49
  scale: any;
50
50
  horizontal: any;
51
51
  };
52
- export declare function getChildren(props: any, childComponents: any, calculatedProps: any): any;
52
+ export declare function getChildren(initialProps: any, childComponents: any, calculatedProps: any): any;
53
53
  //# sourceMappingURL=helper-methods.d.ts.map
@@ -48,13 +48,13 @@ function fillData(props, datasets) {
48
48
  var indexOffset = 0;
49
49
  var isDate = dataset[0] && dataset[0]._x instanceof Date;
50
50
  var filledInData = xArr.map(function (x, index) {
51
- x = Number(x);
51
+ var parsedX = Number(x);
52
52
  var datum = dataset[index - indexOffset];
53
53
 
54
54
  if (datum) {
55
55
  var x1 = isDate ? datum._x.getTime() : datum._x;
56
56
 
57
- if (x1 === x) {
57
+ if (x1 === parsedX) {
58
58
  return datum;
59
59
  }
60
60
 
@@ -62,21 +62,21 @@ function fillData(props, datasets) {
62
62
 
63
63
  var _y = fillInMissingData ? 0 : null;
64
64
 
65
- x = isDate ? new Date(x) : x;
65
+ parsedX = isDate ? new Date(parsedX) : parsedX;
66
66
  return {
67
- x: x,
67
+ x: parsedX,
68
68
  y: _y,
69
- _x: x,
69
+ _x: parsedX,
70
70
  _y: _y
71
71
  };
72
72
  }
73
73
 
74
74
  var y = fillInMissingData ? 0 : null;
75
- x = isDate ? new Date(x) : x;
75
+ parsedX = isDate ? new Date(parsedX) : parsedX;
76
76
  return {
77
- x: x,
77
+ x: parsedX,
78
78
  y: y,
79
- _x: x,
79
+ _x: parsedX,
80
80
  _y: y
81
81
  };
82
82
  });
@@ -140,14 +140,14 @@ function stackData(props, childComponents) {
140
140
  });
141
141
  }
142
142
 
143
- export function getCalculatedProps(props, childComponents) {
144
- childComponents = childComponents || React.Children.toArray(props.children);
143
+ export function getCalculatedProps(initialProps, childComponents) {
144
+ var children = childComponents || React.Children.toArray(initialProps.children);
145
145
  var role = "stack";
146
- props = Helpers.modifyProps(props, fallbackProps, role);
146
+ var props = Helpers.modifyProps(initialProps, fallbackProps, role);
147
147
  var style = Wrapper.getStyle(props.theme, props.style, role);
148
- var categories = props.categories || Wrapper.getCategories(props, childComponents);
149
- var datasets = props.datasets || stackData(props, childComponents);
150
- var children = childComponents.map(function (c, i) {
148
+ var categories = props.categories || Wrapper.getCategories(props, children);
149
+ var datasets = props.datasets || stackData(props, children);
150
+ var clonedChildren = children.map(function (c, i) {
151
151
  return /*#__PURE__*/React.cloneElement(c, {
152
152
  data: datasets[i]
153
153
  });
@@ -155,10 +155,10 @@ export function getCalculatedProps(props, childComponents) {
155
155
  var domain = {
156
156
  x: Wrapper.getDomain(_assign({}, props, {
157
157
  categories: categories
158
- }), "x", children),
158
+ }), "x", clonedChildren),
159
159
  y: Wrapper.getDomain(_assign({}, props, {
160
160
  categories: categories
161
- }), "y", children)
161
+ }), "y", clonedChildren)
162
162
  };
163
163
  var range = props.range || {
164
164
  x: Helpers.getRange(props, "x"),
@@ -172,9 +172,8 @@ export function getCalculatedProps(props, childComponents) {
172
172
  x: baseScale.x.domain(domain.x).range(props.horizontal ? range.y : range.x),
173
173
  y: baseScale.y.domain(domain.y).range(props.horizontal ? range.x : range.y)
174
174
  };
175
- var _props = props,
176
- colorScale = _props.colorScale,
177
- horizontal = _props.horizontal;
175
+ var colorScale = props.colorScale,
176
+ horizontal = props.horizontal;
178
177
  return {
179
178
  datasets: datasets,
180
179
  categories: categories,
@@ -260,18 +259,17 @@ function getColorScale(props, child) {
260
259
  return props.theme ? colorScaleOptions || props.theme.props.colorScale : colorScaleOptions;
261
260
  }
262
261
 
263
- export function getChildren(props, childComponents, calculatedProps) {
264
- props = Helpers.modifyProps(props, fallbackProps, "stack");
265
- childComponents = childComponents || React.Children.toArray(props.children);
266
- calculatedProps = calculatedProps || getCalculatedProps(props, childComponents);
267
- var _calculatedProps = calculatedProps,
268
- datasets = _calculatedProps.datasets;
269
- var childProps = getChildProps(props, calculatedProps);
262
+ export function getChildren(initialProps, childComponents, calculatedProps) {
263
+ var props = Helpers.modifyProps(initialProps, fallbackProps, "stack");
264
+ var children = childComponents || React.Children.toArray(props.children);
265
+ var newCalculatedProps = calculatedProps || getCalculatedProps(props, children);
266
+ var datasets = newCalculatedProps.datasets;
267
+ var childProps = getChildProps(props, newCalculatedProps);
270
268
  var parentName = props.name || "stack";
271
- return childComponents.map(function (child, index) {
269
+ return children.map(function (child, index) {
272
270
  var role = child.type && child.type.role;
273
271
  var data = datasets[index];
274
- var style = Wrapper.getChildStyle(child, index, calculatedProps);
272
+ var style = Wrapper.getChildStyle(child, index, newCalculatedProps);
275
273
  var labels = props.labels ? getLabels(props, datasets, index) : child.props.labels;
276
274
  var name = child.props.name || "".concat(parentName, "-").concat(role, "-").concat(index);
277
275
  return /*#__PURE__*/React.cloneElement(child, _assign({
@@ -38,6 +38,7 @@ export declare const VictoryStack: React.NamedExoticComponent<VictoryStackProps>
38
38
  theme?: React.Validator<import("victory-core").VictoryThemeDefinition | null | undefined> | undefined;
39
39
  animate?: React.Validator<boolean | import("victory-core").AnimatePropTypeInterface | null | undefined> | undefined;
40
40
  containerComponent?: React.Validator<React.ReactElement<any, string | React.JSXElementConstructor<any>> | null | undefined> | undefined;
41
+ disableInlineStyles?: React.Validator<boolean | null | undefined> | undefined;
41
42
  domainPadding?: React.Validator<import("victory-core").ForAxes<import("victory-core").PaddingType> | null | undefined> | undefined;
42
43
  externalEventMutations?: React.Validator<import("victory-core").EventCallbackInterface<string | string[], import("victory-core").StringOrNumberOrList>[] | null | undefined> | undefined;
43
44
  groupComponent?: React.Validator<React.ReactElement<any, string | React.JSXElementConstructor<any>> | null | undefined> | undefined;
@@ -28,16 +28,17 @@ var defaultProps = {
28
28
  };
29
29
 
30
30
  var VictoryStackBase = function (initialProps) {
31
- // eslint-disable-next-line no-use-before-define
32
31
  var role = VictoryStack.role;
33
- initialProps = _objectSpread(_objectSpread({}, defaultProps), initialProps);
32
+ var propsWithDefaults = React.useMemo(function () {
33
+ return _objectSpread(_objectSpread({}, defaultProps), initialProps);
34
+ }, [initialProps]);
34
35
 
35
36
  var _Hooks$useAnimationSt = Hooks.useAnimationState(),
36
37
  setAnimationState = _Hooks$useAnimationSt.setAnimationState,
37
38
  getAnimationProps = _Hooks$useAnimationSt.getAnimationProps,
38
39
  getProps = _Hooks$useAnimationSt.getProps;
39
40
 
40
- var props = getProps(initialProps);
41
+ var props = getProps(propsWithDefaults);
41
42
  var modifiedProps = Helpers.modifyProps(props, fallbackProps, role);
42
43
  var eventKey = modifiedProps.eventKey,
43
44
  containerComponent = modifiedProps.containerComponent,
@@ -91,8 +92,8 @@ var VictoryStackBase = function (initialProps) {
91
92
  return {};
92
93
  }, [standalone, domain, scale, width, height, theme, style, horizontal, polar, name]);
93
94
  var userProps = React.useMemo(function () {
94
- return UserProps.getSafeUserProps(initialProps);
95
- }, [initialProps]);
95
+ return UserProps.getSafeUserProps(propsWithDefaults);
96
+ }, [propsWithDefaults]);
96
97
  var container = React.useMemo(function () {
97
98
  if (standalone) {
98
99
  var defaultContainerProps = _defaults({}, containerComponent.props, containerProps, userProps);
@@ -105,15 +106,15 @@ var VictoryStackBase = function (initialProps) {
105
106
  var events = React.useMemo(function () {
106
107
  return Wrapper.getAllEvents(props);
107
108
  }, [props]);
108
- var previousProps = Hooks.usePreviousProps(initialProps);
109
+ var previousProps = Hooks.usePreviousProps(propsWithDefaults);
109
110
  React.useEffect(function () {
110
111
  // This is called before dismount to keep state in sync
111
112
  return function () {
112
- if (initialProps.animate) {
113
- setAnimationState(previousProps, initialProps);
113
+ if (propsWithDefaults.animate) {
114
+ setAnimationState(previousProps, propsWithDefaults);
114
115
  }
115
116
  };
116
- }, [setAnimationState, previousProps, initialProps]);
117
+ }, [setAnimationState, previousProps, propsWithDefaults]);
117
118
 
118
119
  if (!_isEmpty(events)) {
119
120
  return /*#__PURE__*/React.createElement(VictorySharedEvents, {
@@ -1,4 +1,4 @@
1
- export declare function getCalculatedProps(props: any, childComponents: any): {
1
+ export declare function getCalculatedProps(initialProps: any, childComponents: any): {
2
2
  datasets: any;
3
3
  categories: any;
4
4
  range: any;
@@ -49,5 +49,5 @@ export declare function getChildProps(props: any, calculatedProps: any): {
49
49
  scale: any;
50
50
  horizontal: any;
51
51
  };
52
- export declare function getChildren(props: any, childComponents: any, calculatedProps: any): any;
52
+ export declare function getChildren(initialProps: any, childComponents: any, calculatedProps: any): any;
53
53
  //# sourceMappingURL=helper-methods.d.ts.map
@@ -62,13 +62,13 @@ function fillData(props, datasets) {
62
62
  var indexOffset = 0;
63
63
  var isDate = dataset[0] && dataset[0]._x instanceof Date;
64
64
  var filledInData = xArr.map(function (x, index) {
65
- x = Number(x);
65
+ var parsedX = Number(x);
66
66
  var datum = dataset[index - indexOffset];
67
67
 
68
68
  if (datum) {
69
69
  var x1 = isDate ? datum._x.getTime() : datum._x;
70
70
 
71
- if (x1 === x) {
71
+ if (x1 === parsedX) {
72
72
  return datum;
73
73
  }
74
74
 
@@ -76,21 +76,21 @@ function fillData(props, datasets) {
76
76
 
77
77
  var _y = fillInMissingData ? 0 : null;
78
78
 
79
- x = isDate ? new Date(x) : x;
79
+ parsedX = isDate ? new Date(parsedX) : parsedX;
80
80
  return {
81
- x: x,
81
+ x: parsedX,
82
82
  y: _y,
83
- _x: x,
83
+ _x: parsedX,
84
84
  _y: _y
85
85
  };
86
86
  }
87
87
 
88
88
  var y = fillInMissingData ? 0 : null;
89
- x = isDate ? new Date(x) : x;
89
+ parsedX = isDate ? new Date(parsedX) : parsedX;
90
90
  return {
91
- x: x,
91
+ x: parsedX,
92
92
  y: y,
93
- _x: x,
93
+ _x: parsedX,
94
94
  _y: y
95
95
  };
96
96
  });
@@ -155,17 +155,19 @@ function stackData(props, childComponents) {
155
155
  });
156
156
  }
157
157
 
158
- function getCalculatedProps(props, childComponents) {
159
- childComponents = childComponents || _react.default.Children.toArray(props.children);
158
+ function getCalculatedProps(initialProps, childComponents) {
159
+ var children = childComponents || _react.default.Children.toArray(initialProps.children);
160
+
160
161
  var role = "stack";
161
- props = _victoryCore.Helpers.modifyProps(props, fallbackProps, role);
162
+
163
+ var props = _victoryCore.Helpers.modifyProps(initialProps, fallbackProps, role);
162
164
 
163
165
  var style = _victoryCore.Wrapper.getStyle(props.theme, props.style, role);
164
166
 
165
- var categories = props.categories || _victoryCore.Wrapper.getCategories(props, childComponents);
167
+ var categories = props.categories || _victoryCore.Wrapper.getCategories(props, children);
166
168
 
167
- var datasets = props.datasets || stackData(props, childComponents);
168
- var children = childComponents.map(function (c, i) {
169
+ var datasets = props.datasets || stackData(props, children);
170
+ var clonedChildren = children.map(function (c, i) {
169
171
  return /*#__PURE__*/_react.default.cloneElement(c, {
170
172
  data: datasets[i]
171
173
  });
@@ -173,10 +175,10 @@ function getCalculatedProps(props, childComponents) {
173
175
  var domain = {
174
176
  x: _victoryCore.Wrapper.getDomain((0, _assign2.default)({}, props, {
175
177
  categories: categories
176
- }), "x", children),
178
+ }), "x", clonedChildren),
177
179
  y: _victoryCore.Wrapper.getDomain((0, _assign2.default)({}, props, {
178
180
  categories: categories
179
- }), "y", children)
181
+ }), "y", clonedChildren)
180
182
  };
181
183
  var range = props.range || {
182
184
  x: _victoryCore.Helpers.getRange(props, "x"),
@@ -190,9 +192,8 @@ function getCalculatedProps(props, childComponents) {
190
192
  x: baseScale.x.domain(domain.x).range(props.horizontal ? range.y : range.x),
191
193
  y: baseScale.y.domain(domain.y).range(props.horizontal ? range.x : range.y)
192
194
  };
193
- var _props = props,
194
- colorScale = _props.colorScale,
195
- horizontal = _props.horizontal;
195
+ var colorScale = props.colorScale,
196
+ horizontal = props.horizontal;
196
197
  return {
197
198
  datasets: datasets,
198
199
  categories: categories,
@@ -282,19 +283,20 @@ function getColorScale(props, child) {
282
283
  return props.theme ? colorScaleOptions || props.theme.props.colorScale : colorScaleOptions;
283
284
  }
284
285
 
285
- function getChildren(props, childComponents, calculatedProps) {
286
- props = _victoryCore.Helpers.modifyProps(props, fallbackProps, "stack");
287
- childComponents = childComponents || _react.default.Children.toArray(props.children);
288
- calculatedProps = calculatedProps || getCalculatedProps(props, childComponents);
289
- var _calculatedProps = calculatedProps,
290
- datasets = _calculatedProps.datasets;
291
- var childProps = getChildProps(props, calculatedProps);
286
+ function getChildren(initialProps, childComponents, calculatedProps) {
287
+ var props = _victoryCore.Helpers.modifyProps(initialProps, fallbackProps, "stack");
288
+
289
+ var children = childComponents || _react.default.Children.toArray(props.children);
290
+
291
+ var newCalculatedProps = calculatedProps || getCalculatedProps(props, children);
292
+ var datasets = newCalculatedProps.datasets;
293
+ var childProps = getChildProps(props, newCalculatedProps);
292
294
  var parentName = props.name || "stack";
293
- return childComponents.map(function (child, index) {
295
+ return children.map(function (child, index) {
294
296
  var role = child.type && child.type.role;
295
297
  var data = datasets[index];
296
298
 
297
- var style = _victoryCore.Wrapper.getChildStyle(child, index, calculatedProps);
299
+ var style = _victoryCore.Wrapper.getChildStyle(child, index, newCalculatedProps);
298
300
 
299
301
  var labels = props.labels ? getLabels(props, datasets, index) : child.props.labels;
300
302
  var name = child.props.name || "".concat(parentName, "-").concat(role, "-").concat(index);
@@ -38,6 +38,7 @@ export declare const VictoryStack: React.NamedExoticComponent<VictoryStackProps>
38
38
  theme?: React.Validator<import("victory-core").VictoryThemeDefinition | null | undefined> | undefined;
39
39
  animate?: React.Validator<boolean | import("victory-core").AnimatePropTypeInterface | null | undefined> | undefined;
40
40
  containerComponent?: React.Validator<React.ReactElement<any, string | React.JSXElementConstructor<any>> | null | undefined> | undefined;
41
+ disableInlineStyles?: React.Validator<boolean | null | undefined> | undefined;
41
42
  domainPadding?: React.Validator<import("victory-core").ForAxes<import("victory-core").PaddingType> | null | undefined> | undefined;
42
43
  externalEventMutations?: React.Validator<import("victory-core").EventCallbackInterface<string | string[], import("victory-core").StringOrNumberOrList>[] | null | undefined> | undefined;
43
44
  groupComponent?: React.Validator<React.ReactElement<any, string | React.JSXElementConstructor<any>> | null | undefined> | undefined;
@@ -45,16 +45,18 @@ var defaultProps = {
45
45
  };
46
46
 
47
47
  var VictoryStackBase = function (initialProps) {
48
- // eslint-disable-next-line no-use-before-define
49
48
  var role = VictoryStack.role;
50
- initialProps = _objectSpread(_objectSpread({}, defaultProps), initialProps);
49
+
50
+ var propsWithDefaults = _react.default.useMemo(function () {
51
+ return _objectSpread(_objectSpread({}, defaultProps), initialProps);
52
+ }, [initialProps]);
51
53
 
52
54
  var _Hooks$useAnimationSt = _victoryCore.Hooks.useAnimationState(),
53
55
  setAnimationState = _Hooks$useAnimationSt.setAnimationState,
54
56
  getAnimationProps = _Hooks$useAnimationSt.getAnimationProps,
55
57
  getProps = _Hooks$useAnimationSt.getProps;
56
58
 
57
- var props = getProps(initialProps);
59
+ var props = getProps(propsWithDefaults);
58
60
 
59
61
  var modifiedProps = _victoryCore.Helpers.modifyProps(props, fallbackProps, role);
60
62
 
@@ -114,8 +116,8 @@ var VictoryStackBase = function (initialProps) {
114
116
  }, [standalone, domain, scale, width, height, theme, style, horizontal, polar, name]);
115
117
 
116
118
  var userProps = _react.default.useMemo(function () {
117
- return _victoryCore.UserProps.getSafeUserProps(initialProps);
118
- }, [initialProps]);
119
+ return _victoryCore.UserProps.getSafeUserProps(propsWithDefaults);
120
+ }, [propsWithDefaults]);
119
121
 
120
122
  var container = _react.default.useMemo(function () {
121
123
  if (standalone) {
@@ -130,16 +132,16 @@ var VictoryStackBase = function (initialProps) {
130
132
  return _victoryCore.Wrapper.getAllEvents(props);
131
133
  }, [props]);
132
134
 
133
- var previousProps = _victoryCore.Hooks.usePreviousProps(initialProps);
135
+ var previousProps = _victoryCore.Hooks.usePreviousProps(propsWithDefaults);
134
136
 
135
137
  _react.default.useEffect(function () {
136
138
  // This is called before dismount to keep state in sync
137
139
  return function () {
138
- if (initialProps.animate) {
139
- setAnimationState(previousProps, initialProps);
140
+ if (propsWithDefaults.animate) {
141
+ setAnimationState(previousProps, propsWithDefaults);
140
142
  }
141
143
  };
142
- }, [setAnimationState, previousProps, initialProps]);
144
+ }, [setAnimationState, previousProps, propsWithDefaults]);
143
145
 
144
146
  if (!(0, _isEmpty2.default)(events)) {
145
147
  return /*#__PURE__*/_react.default.createElement(_victorySharedEvents.VictorySharedEvents, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "victory-stack",
3
- "version": "36.8.1",
3
+ "version": "36.8.3",
4
4
  "description": "Stack Layout Component for Victory",
5
5
  "keywords": [
6
6
  "data visualization",
@@ -23,8 +23,8 @@
23
23
  "lodash": "^4.17.19",
24
24
  "prop-types": "^15.8.1",
25
25
  "react-fast-compare": "^3.2.0",
26
- "victory-core": "^36.8.1",
27
- "victory-shared-events": "^36.8.1"
26
+ "victory-core": "^36.8.3",
27
+ "victory-shared-events": "^36.8.3"
28
28
  },
29
29
  "peerDependencies": {
30
30
  "react": ">=16.6.0"
@@ -26,22 +26,22 @@ function fillData(props, datasets) {
26
26
  let indexOffset = 0;
27
27
  const isDate = dataset[0] && dataset[0]._x instanceof Date;
28
28
  const filledInData = xArr.map((x: number | Date, index) => {
29
- x = Number(x);
29
+ let parsedX: number | Date = Number(x);
30
30
  const datum = dataset[index - indexOffset];
31
31
 
32
32
  if (datum) {
33
33
  const x1 = isDate ? datum._x.getTime() : datum._x;
34
- if (x1 === x) {
34
+ if (x1 === parsedX) {
35
35
  return datum;
36
36
  }
37
37
  indexOffset++;
38
38
  const y = fillInMissingData ? 0 : null;
39
- x = isDate ? new Date(x) : x;
40
- return { x, y, _x: x, _y: y };
39
+ parsedX = isDate ? new Date(parsedX) : parsedX;
40
+ return { x: parsedX, y, _x: parsedX, _y: y };
41
41
  }
42
42
  const y = fillInMissingData ? 0 : null;
43
- x = isDate ? new Date(x) : x;
44
- return { x, y, _x: x, _y: y };
43
+ parsedX = isDate ? new Date(parsedX) : parsedX;
44
+ return { x: parsedX, y, _x: parsedX, _y: y };
45
45
  });
46
46
 
47
47
  return filledInData;
@@ -117,20 +117,28 @@ function stackData(props, childComponents) {
117
117
  return datasets.map((d, i) => addLayoutData(props, datasets, i));
118
118
  }
119
119
 
120
- export function getCalculatedProps(props, childComponents) {
121
- childComponents = childComponents || React.Children.toArray(props.children);
120
+ export function getCalculatedProps(initialProps, childComponents) {
121
+ const children =
122
+ childComponents || React.Children.toArray(initialProps.children);
122
123
  const role = "stack";
123
- props = Helpers.modifyProps(props, fallbackProps, role);
124
+ const props = Helpers.modifyProps(initialProps, fallbackProps, role);
124
125
  const style = Wrapper.getStyle(props.theme, props.style, role);
125
- const categories =
126
- props.categories || Wrapper.getCategories(props, childComponents);
127
- const datasets = props.datasets || stackData(props, childComponents);
128
- const children = childComponents.map((c, i) => {
126
+ const categories = props.categories || Wrapper.getCategories(props, children);
127
+ const datasets = props.datasets || stackData(props, children);
128
+ const clonedChildren = children.map((c, i) => {
129
129
  return React.cloneElement(c, { data: datasets[i] });
130
130
  });
131
131
  const domain = {
132
- x: Wrapper.getDomain(assign({}, props, { categories }), "x", children),
133
- y: Wrapper.getDomain(assign({}, props, { categories }), "y", children),
132
+ x: Wrapper.getDomain(
133
+ assign({}, props, { categories }),
134
+ "x",
135
+ clonedChildren,
136
+ ),
137
+ y: Wrapper.getDomain(
138
+ assign({}, props, { categories }),
139
+ "y",
140
+ clonedChildren,
141
+ ),
134
142
  };
135
143
  const range = props.range || {
136
144
  x: Helpers.getRange(props, "x"),
@@ -224,18 +232,18 @@ function getColorScale(props, child) {
224
232
  : colorScaleOptions;
225
233
  }
226
234
 
227
- export function getChildren(props, childComponents, calculatedProps) {
228
- props = Helpers.modifyProps(props, fallbackProps, "stack");
229
- childComponents = childComponents || React.Children.toArray(props.children);
230
- calculatedProps =
231
- calculatedProps || getCalculatedProps(props, childComponents);
232
- const { datasets } = calculatedProps;
233
- const childProps = getChildProps(props, calculatedProps);
235
+ export function getChildren(initialProps, childComponents, calculatedProps) {
236
+ const props = Helpers.modifyProps(initialProps, fallbackProps, "stack");
237
+ const children = childComponents || React.Children.toArray(props.children);
238
+ const newCalculatedProps =
239
+ calculatedProps || getCalculatedProps(props, children);
240
+ const { datasets } = newCalculatedProps;
241
+ const childProps = getChildProps(props, newCalculatedProps);
234
242
  const parentName = props.name || "stack";
235
- return childComponents.map((child, index) => {
243
+ return children.map((child, index) => {
236
244
  const role = child.type && child.type.role;
237
245
  const data = datasets[index];
238
- const style = Wrapper.getChildStyle(child, index, calculatedProps);
246
+ const style = Wrapper.getChildStyle(child, index, newCalculatedProps);
239
247
  const labels = props.labels
240
248
  ? getLabels(props, datasets, index)
241
249
  : child.props.labels;
@@ -61,13 +61,15 @@ const defaultProps = {
61
61
  };
62
62
 
63
63
  const VictoryStackBase = (initialProps: VictoryStackProps) => {
64
- // eslint-disable-next-line no-use-before-define
65
64
  const { role } = VictoryStack;
66
- initialProps = { ...defaultProps, ...initialProps };
65
+ const propsWithDefaults = React.useMemo(
66
+ () => ({ ...defaultProps, ...initialProps }),
67
+ [initialProps],
68
+ );
67
69
  const { setAnimationState, getAnimationProps, getProps } =
68
70
  Hooks.useAnimationState();
69
71
 
70
- const props = getProps(initialProps);
72
+ const props = getProps(propsWithDefaults);
71
73
 
72
74
  const modifiedProps = Helpers.modifyProps(props, fallbackProps, role);
73
75
  const {
@@ -134,8 +136,8 @@ const VictoryStackBase = (initialProps: VictoryStackProps) => {
134
136
  name,
135
137
  ]);
136
138
  const userProps = React.useMemo(
137
- () => UserProps.getSafeUserProps(initialProps),
138
- [initialProps],
139
+ () => UserProps.getSafeUserProps(propsWithDefaults),
140
+ [propsWithDefaults],
139
141
  );
140
142
 
141
143
  const container = React.useMemo(() => {
@@ -161,16 +163,16 @@ const VictoryStackBase = (initialProps: VictoryStackProps) => {
161
163
  return Wrapper.getAllEvents(props);
162
164
  }, [props]);
163
165
 
164
- const previousProps = Hooks.usePreviousProps(initialProps);
166
+ const previousProps = Hooks.usePreviousProps(propsWithDefaults);
165
167
 
166
168
  React.useEffect(() => {
167
169
  // This is called before dismount to keep state in sync
168
170
  return () => {
169
- if (initialProps.animate) {
170
- setAnimationState(previousProps, initialProps);
171
+ if (propsWithDefaults.animate) {
172
+ setAnimationState(previousProps, propsWithDefaults);
171
173
  }
172
174
  };
173
- }, [setAnimationState, previousProps, initialProps]);
175
+ }, [setAnimationState, previousProps, propsWithDefaults]);
174
176
 
175
177
  if (!isEmpty(events)) {
176
178
  return (