Open trevorpfiz opened 3 months ago
To resolve the warning message, you need to ensure that the functions used within the Reanimated worklets are properly marked as worklets or are wrapped with runOnJS
.
Here's an example of how to correctly use runOnJS
with react-native-gesture-handler
:
import { Gesture, GestureDetector } from 'react-native-gesture-handler';
import { runOnJS } from 'react-native-reanimated';
const gesture = Gesture.Pan()
.onUpdate((event) => {
'worklet';
// Your worklet code here
})
.onEnd((event) => {
'worklet';
runOnJS(onGestureEnd)(event);
});
const onGestureEnd = (event) => {
// Your JS thread code here
};
<GestureDetector gesture={gesture}>
{/* Your carousel component */}
</GestureDetector>
In this example, the onEnd
callback is wrapped with runOnJS
to ensure it runs on the JS thread. Make sure to apply this pattern to all relevant callbacks in your gesture configuration.
Additionally, ensure that your project is using compatible versions of react-native-reanimated-carousel
and react-native-gesture-handler
. The react-native-reanimated-carousel
has been updated to use the new RNGH API, which requires react-native-gesture-handler
version >=2.9.0
[1].
If you follow these steps, the warning should be resolved.
To continue talking to Dosu, mention @dosu.
Does this PR appear to resolve this? 🙏
Does this PR appear to resolve this? 🙏
not totally sure, maybe? how does https://docs.swmansion.com/react-native-gesture-handler/docs/#automatic-workletization-of-gesture-callbacks relate to all this?
Does this PR appear to resolve this? 🙏
not totally sure, maybe? how does https://docs.swmansion.com/react-native-gesture-handler/docs/#automatic-workletization-of-gesture-callbacks relate to all this?
yeah! In #577, see "Discussion of the bug" / "But why doesn't the react-native-reanimated/plugin
babel plugin automatically workletify these handlers?"
Same issue here! Is there any workaround for the moment?
+1
+1
I think this should be fixed with
which was released in v4.0.0-canary.13 (and included in releases thereafter)
I think this should be fixed with
which was released in v4.0.0-canary.13 (and included in releases thereafter)
+1 to the issue described above. @nmassey, it is certainly possible I did something improper. However, I thought I would share that after installing "^4.0.0-canary.13"
of react-native-reanimated-carousel,
the onPress
callback for <Pagination.Basic ... onPress />
was not firing.
Cheers.
Hi @softwaresean - there was a bug (#676) introduced in canary.13. It was fixed via #677 which was released with canary.15.
If you update to canary.15 or higher (the latest is 17), does this fix your issue?
I am facing the same issue. But I am not using gesture handler anywhere directly. I have installed it for drawer navigation. How to fix this?
Describe the bug Getting this error:
To Reproduce Steps to reproduce the behavior:
"react-native-reanimated-carousel": "4.0.0-alpha.12"
in my project https://github.com/trevorpfiz/project-hyperI created a snack, but can't see the error there: https://snack.expo.dev/@elektrikspark/joyous-violet-kiwi
Expected behavior I would expect no issues with this library and
react-native-gesture-handler
Versions (please complete the following information):
Smartphone (please complete the following information):
Additional context Let me know if more is needed, thanks!