Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/core/components/wrapper/BaseAnimationWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,16 @@ export abstract class BaseAnimationWrapper<P extends AnimationWrapperProps> exte

public abstract finishAnimation(): void;
protected abstract renderAnimation(content: React.ReactNode): React.ReactNode;
protected abstract updateCompositeAnimation(): void;
protected abstract updateCompositeAnimation(nextProps?: AnimationWrapperProps): void;

protected _compositeAnimation: Animated.CompositeAnimation | undefined;

public shouldComponentUpdate(nextProps: Readonly<AnimationWrapperProps>, _: any): boolean {
return nextProps.animationConfig !== this.props.animationConfig;
const shouldUpdate = nextProps.animationConfig !== this.props.animationConfig;
if (shouldUpdate) {
this.updateCompositeAnimation(nextProps);
}
return shouldUpdate;
}

public componentDidMount(): void {
Expand Down
8 changes: 4 additions & 4 deletions src/core/components/wrapper/JsonAnimationWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,10 @@ export class JsonAnimationWrapper extends BaseAnimationWrapper<JsonAnimationProp
return {};
}

protected updateCompositeAnimation(): void {
this._updateAnimatedArray(this.props);
this._updateCompositeAnimation(this.props);
this._updateTransformsArray(this.props);
protected updateCompositeAnimation(newProps?: JsonAnimationProps): void {
this._updateAnimatedArray(newProps ?? this.props);
this._updateCompositeAnimation(newProps ?? this.props);
this._updateTransformsArray(newProps ?? this.props);
}
Comment on lines +59 to 63
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Verification agent

🧩 Analysis chain

Good implementation of animation optimization

The method now accepts an optional newProps parameter and uses the nullish coalescing operator to fall back to current props when needed. This implementation properly supports the optimization introduced in the base class and ensures that animations can be prepared with upcoming props.

One minor recommendation - consider enabling the native driver for better performance:

- useNativeDriver: false
+ useNativeDriver: true

However, only do this if all animated properties are compatible with the native driver (opacity and transform properties). Style properties like width, height, etc. aren't compatible with the native driver.

To verify which properties in your animations might not be compatible with the native driver:


🏁 Script executed:

#!/bin/bash
# Find all animation properties that might not be compatible with native driver
grep -n "case \"" src/core/components/wrapper/JsonAnimationWrapper.tsx | grep -v "translate\|rotate\|scale\|opacity" | sort

Length of output: 245


Updated Recommendation: Verify Animated Properties for Native Driver Compatibility

The refactored implementation using an optional newProps parameter and fallback to current props is well done. However, our recent verification shows that the component animates properties such as "skewX", "skewY", "width", and "height"—which are not compatible with the native driver.

  • If you plan to enable the native driver (i.e., using useNativeDriver: true), please first ensure that all animated properties are natively supported (typically only opacity and transform properties are safe).
  • Otherwise, continue using useNativeDriver: false or consider refactoring the component to animate only the supported properties.

Committable suggestion skipped: line range outside the PR's diff.


private _updateAnimatedArray(props: JsonAnimationProps): void {
Expand Down