Guidelines for scheduling functions between JavaScript and UI threads using React Native Worklets. This skill covers when and how to use scheduleOnRN and scheduleOnUI, proper function definition patterns, and avoiding unnecessary worklet directives.
Never use the "worklet" directive unless explicitly requested. In 99.9% of cases, there is no need to use it. scheduleOnUI handles worklet conversion automatically, so the directive is unnecessary. This also applies to gesture detector callbacks - you don't need to add the "worklet" directive in gesture handler callbacks.
Use scheduleOnRN and scheduleOnUI from react-native-worklets instead of runOnJS and runOnUI from react-native-reanimated.
Fornisce linee guida per i worklet nativi di React per la pianificazione delle funzioni tra thread JS e UI. Si applica alle attività che coinvolgono scheduleOnRN, scheduleOnUI, worklet, pianificazione dei thread, useAnimatedReaction, gestori di gesti o chiamate di funzioni multithread. Fonte: sovranbitcoin/sovran.