Skip to content

Commit

Permalink
Fix victory-group animation
Browse files Browse the repository at this point in the history
  • Loading branch information
KenanYusuf committed Jan 16, 2024
1 parent cb630fa commit d9e0fd3
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions packages/victory-group/src/victory-group.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,11 @@ const VictoryGroupBase: React.FC<VictoryGroupProps> = (initialProps) => {
const role = VictoryGroup?.role;
const { getAnimationProps, setAnimationState, getProps } =
Hooks.useAnimationState();
initialProps = { ...defaultProps, ...initialProps };
const props = getProps(initialProps);
const propsWithDefaults = React.useMemo(
() => ({ ...defaultProps, ...initialProps }),
[initialProps],
);
const props = getProps(propsWithDefaults);

const modifiedProps = Helpers.modifyProps(props, fallbackProps, role);
const {
Expand Down Expand Up @@ -132,8 +135,8 @@ const VictoryGroupBase: React.FC<VictoryGroupProps> = (initialProps) => {
]);

const userProps = React.useMemo(
() => UserProps.getSafeUserProps(initialProps),
[initialProps],
() => UserProps.getSafeUserProps(propsWithDefaults),
[propsWithDefaults],
);

const container = React.useMemo(() => {
Expand All @@ -160,16 +163,16 @@ const VictoryGroupBase: React.FC<VictoryGroupProps> = (initialProps) => {
return Wrapper.getAllEvents(props);
}, [props]);

const previousProps = Hooks.usePreviousProps(initialProps);
const previousProps = Hooks.usePreviousProps(propsWithDefaults);

React.useEffect(() => {
// This is called before dismount to keep state in sync
return () => {
if (initialProps.animate) {
if (propsWithDefaults.animate) {
setAnimationState(previousProps, props);
}
};
}, [setAnimationState, previousProps, initialProps, props]);
}, [setAnimationState, previousProps, propsWithDefaults, props]);

if (!isEmpty(events)) {
return (
Expand Down

0 comments on commit d9e0fd3

Please sign in to comment.