victory-chart 36.8.1 → 36.8.2

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.
@@ -42,7 +42,9 @@ var defaultProps = {
42
42
  };
43
43
 
44
44
  var VictoryChartImpl = function (initialProps) {
45
- initialProps = _objectSpread(_objectSpread({}, defaultProps), initialProps);
45
+ var propsWithDefaults = React.useMemo(function () {
46
+ return _objectSpread(_objectSpread({}, defaultProps), initialProps);
47
+ }, [initialProps]);
46
48
  var role = "chart";
47
49
 
48
50
  var _Hooks$useAnimationSt = Hooks.useAnimationState(),
@@ -50,7 +52,7 @@ var VictoryChartImpl = function (initialProps) {
50
52
  setAnimationState = _Hooks$useAnimationSt.setAnimationState,
51
53
  getProps = _Hooks$useAnimationSt.getProps;
52
54
 
53
- var props = getProps(initialProps);
55
+ var props = getProps(propsWithDefaults);
54
56
  var modifiedProps = Helpers.modifyProps(props, fallbackProps, role);
55
57
  var desc = modifiedProps.desc,
56
58
  eventKey = modifiedProps.eventKey,
@@ -116,25 +118,25 @@ var VictoryChartImpl = function (initialProps) {
116
118
  }, [desc, domain, height, horizontal, name, origin, polar, scale, standalone, style, title, theme, width]);
117
119
  var container = React.useMemo(function () {
118
120
  if (standalone) {
119
- var defaultContainerProps = _defaults({}, containerComponent.props, containerProps, UserProps.getSafeUserProps(initialProps));
121
+ var defaultContainerProps = _defaults({}, containerComponent.props, containerProps, UserProps.getSafeUserProps(propsWithDefaults));
120
122
 
121
123
  return /*#__PURE__*/React.cloneElement(containerComponent, defaultContainerProps);
122
124
  }
123
125
 
124
126
  return groupComponent;
125
- }, [groupComponent, standalone, containerComponent, containerProps, initialProps]);
127
+ }, [groupComponent, standalone, containerComponent, containerProps, propsWithDefaults]);
126
128
  var events = React.useMemo(function () {
127
129
  return Wrapper.getAllEvents(props);
128
130
  }, [props]);
129
- var previousProps = Hooks.usePreviousProps(initialProps);
131
+ var previousProps = Hooks.usePreviousProps(propsWithDefaults);
130
132
  React.useEffect(function () {
131
133
  // This is called before dismount to keep state in sync
132
134
  return function () {
133
- if (initialProps.animate) {
134
- setAnimationState(previousProps, initialProps);
135
+ if (propsWithDefaults.animate) {
136
+ setAnimationState(previousProps, propsWithDefaults);
135
137
  }
136
138
  };
137
- }, [setAnimationState, previousProps, initialProps]);
139
+ }, [setAnimationState, previousProps, propsWithDefaults]);
138
140
 
139
141
  if (!_isEmpty(events)) {
140
142
  return /*#__PURE__*/React.createElement(VictorySharedEvents, {
@@ -61,7 +61,10 @@ var defaultProps = {
61
61
  };
62
62
 
63
63
  var VictoryChartImpl = function (initialProps) {
64
- initialProps = _objectSpread(_objectSpread({}, defaultProps), initialProps);
64
+ var propsWithDefaults = _react.default.useMemo(function () {
65
+ return _objectSpread(_objectSpread({}, defaultProps), initialProps);
66
+ }, [initialProps]);
67
+
65
68
  var role = "chart";
66
69
 
67
70
  var _Hooks$useAnimationSt = _victoryCore.Hooks.useAnimationState(),
@@ -69,7 +72,7 @@ var VictoryChartImpl = function (initialProps) {
69
72
  setAnimationState = _Hooks$useAnimationSt.setAnimationState,
70
73
  getProps = _Hooks$useAnimationSt.getProps;
71
74
 
72
- var props = getProps(initialProps);
75
+ var props = getProps(propsWithDefaults);
73
76
 
74
77
  var modifiedProps = _victoryCore.Helpers.modifyProps(props, fallbackProps, role);
75
78
 
@@ -142,27 +145,27 @@ var VictoryChartImpl = function (initialProps) {
142
145
 
143
146
  var container = _react.default.useMemo(function () {
144
147
  if (standalone) {
145
- var defaultContainerProps = (0, _defaults2.default)({}, containerComponent.props, containerProps, _victoryCore.UserProps.getSafeUserProps(initialProps));
148
+ var defaultContainerProps = (0, _defaults2.default)({}, containerComponent.props, containerProps, _victoryCore.UserProps.getSafeUserProps(propsWithDefaults));
146
149
  return /*#__PURE__*/_react.default.cloneElement(containerComponent, defaultContainerProps);
147
150
  }
148
151
 
149
152
  return groupComponent;
150
- }, [groupComponent, standalone, containerComponent, containerProps, initialProps]);
153
+ }, [groupComponent, standalone, containerComponent, containerProps, propsWithDefaults]);
151
154
 
152
155
  var events = _react.default.useMemo(function () {
153
156
  return _victoryCore.Wrapper.getAllEvents(props);
154
157
  }, [props]);
155
158
 
156
- var previousProps = _victoryCore.Hooks.usePreviousProps(initialProps);
159
+ var previousProps = _victoryCore.Hooks.usePreviousProps(propsWithDefaults);
157
160
 
158
161
  _react.default.useEffect(function () {
159
162
  // This is called before dismount to keep state in sync
160
163
  return function () {
161
- if (initialProps.animate) {
162
- setAnimationState(previousProps, initialProps);
164
+ if (propsWithDefaults.animate) {
165
+ setAnimationState(previousProps, propsWithDefaults);
163
166
  }
164
167
  };
165
- }, [setAnimationState, previousProps, initialProps]);
168
+ }, [setAnimationState, previousProps, propsWithDefaults]);
166
169
 
167
170
  if (!(0, _isEmpty2.default)(events)) {
168
171
  return /*#__PURE__*/_react.default.createElement(_victorySharedEvents.VictorySharedEvents, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "victory-chart",
3
- "version": "36.8.1",
3
+ "version": "36.8.2",
4
4
  "description": "Chart Component for Victory",
5
5
  "keywords": [
6
6
  "data visualization",
@@ -23,10 +23,10 @@
23
23
  "lodash": "^4.17.19",
24
24
  "prop-types": "^15.8.1",
25
25
  "react-fast-compare": "^3.2.0",
26
- "victory-axis": "^36.8.1",
27
- "victory-core": "^36.8.1",
28
- "victory-polar-axis": "^36.8.1",
29
- "victory-shared-events": "^36.8.1"
26
+ "victory-axis": "^36.8.2",
27
+ "victory-core": "^36.8.2",
28
+ "victory-polar-axis": "^36.8.2",
29
+ "victory-shared-events": "^36.8.2"
30
30
  },
31
31
  "peerDependencies": {
32
32
  "react": ">=16.6.0"
@@ -53,11 +53,14 @@ const defaultProps = {
53
53
  };
54
54
 
55
55
  const VictoryChartImpl: React.FC<VictoryChartProps> = (initialProps) => {
56
- initialProps = { ...defaultProps, ...initialProps };
56
+ const propsWithDefaults = React.useMemo(
57
+ () => ({ ...defaultProps, ...initialProps }),
58
+ [initialProps],
59
+ );
57
60
  const role = "chart";
58
61
  const { getAnimationProps, setAnimationState, getProps } =
59
62
  Hooks.useAnimationState();
60
- const props = getProps(initialProps);
63
+ const props = getProps(propsWithDefaults);
61
64
 
62
65
  const modifiedProps = Helpers.modifyProps(props, fallbackProps, role);
63
66
  const {
@@ -154,7 +157,7 @@ const VictoryChartImpl: React.FC<VictoryChartProps> = (initialProps) => {
154
157
  {},
155
158
  containerComponent.props,
156
159
  containerProps,
157
- UserProps.getSafeUserProps(initialProps),
160
+ UserProps.getSafeUserProps(propsWithDefaults),
158
161
  );
159
162
  return React.cloneElement(containerComponent, defaultContainerProps);
160
163
  }
@@ -164,23 +167,23 @@ const VictoryChartImpl: React.FC<VictoryChartProps> = (initialProps) => {
164
167
  standalone,
165
168
  containerComponent,
166
169
  containerProps,
167
- initialProps,
170
+ propsWithDefaults,
168
171
  ]);
169
172
 
170
173
  const events = React.useMemo(() => {
171
174
  return Wrapper.getAllEvents(props);
172
175
  }, [props]);
173
176
 
174
- const previousProps = Hooks.usePreviousProps(initialProps);
177
+ const previousProps = Hooks.usePreviousProps(propsWithDefaults);
175
178
 
176
179
  React.useEffect(() => {
177
180
  // This is called before dismount to keep state in sync
178
181
  return () => {
179
- if (initialProps.animate) {
180
- setAnimationState(previousProps, initialProps);
182
+ if (propsWithDefaults.animate) {
183
+ setAnimationState(previousProps, propsWithDefaults);
181
184
  }
182
185
  };
183
- }, [setAnimationState, previousProps, initialProps]);
186
+ }, [setAnimationState, previousProps, propsWithDefaults]);
184
187
 
185
188
  if (!isEmpty(events)) {
186
189
  return (