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

Better error when passing easing from 'react-native' instead of 'reanimated' #5639

Merged
merged 36 commits into from
Mar 22, 2024
Merged
Changes from 1 commit
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
9c4e836
Add a good error log
Feb 5, 2024
6b52e25
Refactor
Feb 5, 2024
bf2343c
Fix
Feb 5, 2024
6d544f4
Merge branch 'main' into acynk/no-rn-easing
Feb 5, 2024
949854d
Fix
Feb 5, 2024
700a96d
Update src/reanimated2/animation/timing.ts
Latropos Feb 5, 2024
7ffbf34
Improve message
Feb 5, 2024
cc9cb92
Add dev
Feb 7, 2024
db8da1f
Add comment
Feb 8, 2024
bf35466
Self review
Feb 8, 2024
db734de
Better error format
Feb 8, 2024
21ec0d6
Update src/reanimated2/animation/timing.ts
Latropos Feb 20, 2024
97951df
Merge branch 'main' into acynk/no-rn-easing
Feb 20, 2024
5ab4919
Code review
Feb 20, 2024
e978800
Merge branch 'main' into acynk/no-rn-easing
Feb 21, 2024
b552873
Skip checks on web
Feb 22, 2024
5d952e9
Merge branch 'main' into acynk/no-rn-easing
Feb 22, 2024
1b2ed19
Reneme 'isWorklet' into 'isWorkletFunction'
Feb 22, 2024
9664833
Apply suggestions from code review
Latropos Feb 23, 2024
cbe0a2c
fix
Feb 23, 2024
8ca3364
Remove 'bind' check
Mar 4, 2024
8124a3a
Improve formatting
Mar 4, 2024
762e012
Merge branch 'main' into acynk/no-rn-easing
Mar 5, 2024
b2fa1eb
Code review
Mar 5, 2024
0518206
Don't verify easing in keyframe
Mar 5, 2024
e4756c9
Get rid of function name in error \n and improve
Mar 6, 2024
433c93a
revert changes to EmptyExample.tsx
Mar 6, 2024
70c1fbc
Move checks on JS
Mar 6, 2024
e521d4e
Merge branch 'main' into acynk/no-rn-easing
Mar 6, 2024
83a083d
Update src/reanimated2/commonTypes.ts
Latropos Mar 6, 2024
52a3538
code review
Mar 6, 2024
00ac6fb
refactor
Mar 8, 2024
1597003
Merge branch 'main' into acynk/no-rn-easing
Mar 11, 2024
4c298a5
Add worklet check
Mar 11, 2024
959ef09
Update src/reanimated2/animation/util.ts
Latropos Mar 20, 2024
a2c60a0
Update src/reanimated2/animation/timing.ts
Latropos Mar 20, 2024
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
14 changes: 10 additions & 4 deletions src/reanimated2/animation/timing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,20 @@ export const withTiming = function (

if (userConfig?.easing) {
const { easing } = userConfig;
if (!('__workletHash' in easing)) {
const isFunction: boolean = typeof easing === 'function';
const isWorklet: boolean = !!(
easing as unknown as { __workletHash: number }
)?.__workletHash;
const functionName = typeof easing === 'function' ? easing?.name : '';
const isBound = functionName.startsWith('bound');
Latropos marked this conversation as resolved.
Show resolved Hide resolved

if (!isBound && isFunction && !isWorklet) {
throw new Error(
`[Reanimated] The easing function${
'name' in easing ? ` '${easing.name}'` : ''
} provided to 'withTiming' is not a worklet. Are you sure you didn't import it from react-native? `
`[Reanimated] The easing function ${functionName} provided to 'withTiming' is not a worklet. Are you sure you didn't import it from react-native? `
);
}
}
Latropos marked this conversation as resolved.
Show resolved Hide resolved

return defineAnimation<TimingAnimation>(toValue, () => {
'worklet';
const config: Required<Omit<TimingConfig, 'reduceMotion'>> = {
Expand Down