Understand thread boundaries in react-native-reanimated-carousel
mainThe library splits operations between the UI thread (Worklets) and the JS thread to ensure smooth animations. Understanding this boundary is important for performance and debugging.
UI thread / Worklets handle:
- Animation properties:
handlerOffset,progress,relativeProgress. - Motion, visible ranges, layout transforms, and item animations.
- Gesture handlers and consumer gesture observers.
- Pagination interpolation.
JS thread handles:
- React rendering,
renderItem, andkeyExtractor. - Configuration calls for
onConfigurePanGesture. - Refs and public lifecycle/progress callbacks.
- Layout events (
onLayout), pagination presses, and accessibility label factories.
Cross-thread communication is managed explicitly using scheduleOnRN or scheduleOnUI.