Open
Description
Description
I have a gesture handler that needs to call some external functions. However I discovered that the external functions must be defined above the workletized callback function, otherwise the app crashes when trying to execute the callback.
For example:
const moveLeft = () => {
"worklet";
//stuff goes here
}
const moveRight = () => {
"worklet";
//stuff goes here
}
const gesture = Gesture.Pan()
.onUpdate((e) => {
//some stuff here
})
.onEnd((e) => {
if ("some condition") {
if ("some other condition")
{
moveRight();
} else {
moveLeft();
}
}
});
This works, but
const gesture = Gesture.Pan()
.onUpdate((e) => {
//some stuff here
})
.onEnd((e) => {
if ("some condition") {
if ("some other condition")
{
moveRight();
} else {
moveLeft();
}
}
});
const moveLeft = () => {
"worklet";
//stuff goes here
}
const moveRight = () => {
"worklet";
//stuff goes here
}
This crashes the Expo Go app on my iPhone.
If this is a bug i hope it gets fixed, if it is intended then you should clarify this!
Steps to reproduce
- make a react native gesture with callbacks like onUpdate or onEnd
- within the callback function, call any external function(s) which are defined below the callback function in the file
- the app crashes when that callback is called
Snack or a link to a repository
no repo, code is in the description
Reanimated version
3.17.4
React Native version
0.79.4
Platforms
iOS
JavaScript runtime
None
Workflow
Expo Go
Architecture
Fabric (New Architecture)
Build type
Debug app & dev bundle
Device
Real device
Host machine
Windows
Device model
iphone 13
Acknowledgements
Yes