Migrate runOnUI/runOnJS to scheduleOnUI/scheduleOnRN (#11249)

This commit is contained in:
Tomasz Zawadzki
2026-07-26 21:00:35 +02:00
committed by GitHub
parent d5e335e575
commit 2b9deeeb6a
24 changed files with 102 additions and 109 deletions
+3 -3
View File
@@ -18,12 +18,12 @@ import PagerView, {
type PageScrollStateChangedNativeEventData,
} from 'react-native-pager-view'
import Animated, {
runOnJS,
type SharedValue,
useEvent,
useHandler,
useSharedValue,
} from 'react-native-reanimated'
import {scheduleOnRN} from 'react-native-worklets'
import {useFocusEffect} from '@react-navigation/native'
import {useSetDrawerSwipeDisabled} from '#/state/shell'
@@ -125,7 +125,7 @@ export function Pager({
},
onPageScrollStateChanged(e: PageScrollStateChangedNativeEventData) {
'worklet'
runOnJS(setIsIdle)(e.pageScrollState === 'idle')
scheduleOnRN(setIsIdle, e.pageScrollState === 'idle')
if (dragState.get() === 'idle' && e.pageScrollState === 'settling') {
// This is a programmatic scroll on Android.
// Stay "idle" to match iOS and avoid confusing downstream code.
@@ -137,7 +137,7 @@ export function Pager({
onPageSelected(e: PagerViewOnPageSelectedEventData) {
'worklet'
didInit.set(true)
runOnJS(onPageSelectedJSThread)(e.position)
scheduleOnRN(onPageSelectedJSThread, e.position)
},
},
[parentOnPageScrollStateChanged],
+2 -2
View File
@@ -8,13 +8,13 @@ import {
} from 'react-native'
import Animated, {
type AnimatedRef,
runOnUI,
scrollTo,
type SharedValue,
useAnimatedRef,
useAnimatedStyle,
useSharedValue,
} from 'react-native-reanimated'
import {scheduleOnUI} from 'react-native-worklets'
import {ScrollProvider} from '#/lib/ScrollContext'
import {
@@ -181,7 +181,7 @@ export function PagerWithHeader({
)
const onTabPressed = useCallback(() => {
runOnUI(adjustScrollForOtherPages)('dragging')
scheduleOnUI(adjustScrollForOtherPages, 'dragging')
}, [adjustScrollForOtherPages])
return (
+5 -6
View File
@@ -7,8 +7,6 @@ import {
} from 'react-native'
import Animated, {
interpolate,
runOnJS,
runOnUI,
scrollTo,
type SharedValue,
useAnimatedReaction,
@@ -16,6 +14,7 @@ import Animated, {
useAnimatedStyle,
useSharedValue,
} from 'react-native-reanimated'
import {scheduleOnRN, scheduleOnUI} from 'react-native-worklets'
import {PressableWithHover} from '#/view/com/util/PressableWithHover'
import {BlockDrawerGesture} from '#/view/shell/BlockDrawerGesture'
@@ -126,7 +125,7 @@ export function TabBar({
const progress = dragProgress.get()
const offset = progressToOffset(progress)
// It's unclear why we need to go back to JS here. It seems iOS-specific.
runOnJS(scrollToOffsetJS)(offset)
scheduleOnRN(scrollToOffsetJS, offset)
}
}
},
@@ -303,7 +302,7 @@ export function TabBar({
const onPressItem = useCallback(
(index: number) => {
runOnUI(onPressUIThread)(index)
scheduleOnUI(onPressUIThread, index)
onSelect?.(index)
if (index === selectedPage) {
onPressSelected?.(index)
@@ -409,14 +408,14 @@ function TabBarItem({
const handleLayout = useCallback(
(e: LayoutChangeEvent) => {
runOnUI(onItemLayout)(index, e.nativeEvent.layout)
scheduleOnUI(onItemLayout, index, e.nativeEvent.layout)
},
[index, onItemLayout],
)
const handleTextLayout = useCallback(
(e: LayoutChangeEvent) => {
runOnUI(onTextLayout)(index, e.nativeEvent.layout)
scheduleOnUI(onTextLayout, index, e.nativeEvent.layout)
},
[index, onTextLayout],
)