Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix getAnimatedStyle error when called with component that doesn't have animated styles #6746

Open
wants to merge 1 commit into
base: 3.16-stable
Choose a base branch
from

Conversation

AcostaB
Copy link

@AcostaB AcostaB commented Nov 21, 2024

isEmpty will return false if it is passed in undefined, instead of throwing an error.

Summary

If getAnimatedStyle is passed in a component that doesn't have animated styles, it throws an error saying "Cannot convert undefined or null to object". This happens because jestUtils.ts has an isEmpty function that calls Object.keys with an argument that can potentially be undefined. The arg can potentially be undefined because it comes from const jestAnimatedStyleValue = component.props.jestAnimatedStyle?.value;

This issue was introduced in version 3.16.0.

Test plan

Can be simply tested on a browser console. Just run:

(obj => Object.keys(obj).length === 0)(undefined) // throws error

(obj => !obj || Object.keys(obj).length === 0)(undefined) // returns true as expected

(obj => !obj || Object.keys(obj).length === 0)({test: 'something'}) // returns false as expected

isEmpty will return false if it is passed in undefined
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant