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

Show proper error for transform in UAS #1832

Merged
merged 2 commits into from
Mar 16, 2021
Merged
Changes from 1 commit
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
19 changes: 17 additions & 2 deletions src/reanimated2/Hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -493,13 +493,28 @@ export function useAnimatedStyle(updater, dependencies, adapters) {

// check for invalid usage of shared values in returned object
let wrongKey;
const isError = Object.keys(initial).some((key) => {
const element = initial[key];
const isObjectInvalid = (element, key) => {
const result = typeof element === 'object' && element.value !== undefined;
if (result) {
wrongKey = key;
}
return result;
};
const isError = Object.keys(initial).some((key) => {
const element = initial[key];
let result = false;
if (key === 'transform') {
karol-bisztyga marked this conversation as resolved.
Show resolved Hide resolved
for (const transformItem of element) {
const item = Object.values(transformItem)[0];
result = isObjectInvalid(item, key);
karol-bisztyga marked this conversation as resolved.
Show resolved Hide resolved
if (result) {
break;
}
}
} else {
result = isObjectInvalid(element, key);
}
return result;
});
if (isError && wrongKey !== undefined) {
throw new Error(
Expand Down