@@ -18,9 +18,9 @@ import Animated, {
18
18
Extrapolate ,
19
19
runOnUI ,
20
20
cancelAnimation ,
21
- useWorkletCallback ,
22
21
WithSpringConfig ,
23
22
WithTimingConfig ,
23
+ type SharedValue ,
24
24
} from 'react-native-reanimated' ;
25
25
import { State } from 'react-native-gesture-handler' ;
26
26
import {
@@ -203,7 +203,7 @@ const BottomSheetComponent = forwardRef<BottomSheetMethods, BottomSheetProps>(
203
203
} ) ;
204
204
const animatedContainerOffset = useReactiveSharedValue (
205
205
_providedContainerOffset ?? INITIAL_CONTAINER_OFFSET
206
- ) as Animated . SharedValue < Insets > ;
206
+ ) as SharedValue < Insets > ;
207
207
const animatedHandleHeight = useReactiveSharedValue (
208
208
_providedHandleHeight ?? INITIAL_HANDLE_HEIGHT
209
209
) ;
@@ -528,7 +528,7 @@ const BottomSheetComponent = forwardRef<BottomSheetMethods, BottomSheetProps>(
528
528
/**
529
529
* Calculate the next position based on keyboard state.
530
530
*/
531
- const getNextPosition = useWorkletCallback (
531
+ const getNextPosition = useCallback (
532
532
function getNextPosition ( ) {
533
533
'worklet' ;
534
534
const currentIndex = animatedCurrentIndex . value ;
@@ -663,7 +663,8 @@ const BottomSheetComponent = forwardRef<BottomSheetMethods, BottomSheetProps>(
663
663
//#endregion
664
664
665
665
//#region animation
666
- const stopAnimation = useWorkletCallback ( ( ) => {
666
+ const stopAnimation = useCallback ( ( ) => {
667
+ 'worklet' ;
667
668
cancelAnimation ( animatedPosition ) ;
668
669
isForcedClosing . value = false ;
669
670
animatedAnimationSource . value = ANIMATION_SOURCE . NONE ;
@@ -674,8 +675,9 @@ const BottomSheetComponent = forwardRef<BottomSheetMethods, BottomSheetProps>(
674
675
animatedAnimationSource ,
675
676
animatedAnimationState ,
676
677
] ) ;
677
- const animateToPositionCompleted = useWorkletCallback (
678
+ const animateToPositionCompleted = useCallback (
678
679
function animateToPositionCompleted ( isFinished ?: boolean ) {
680
+ 'worklet' ;
679
681
isForcedClosing . value = false ;
680
682
681
683
if ( ! isFinished ) {
@@ -695,15 +697,24 @@ const BottomSheetComponent = forwardRef<BottomSheetMethods, BottomSheetProps>(
695
697
animatedAnimationState . value = ANIMATION_STATE . STOPPED ;
696
698
animatedNextPosition . value = INITIAL_VALUE ;
697
699
animatedNextPositionIndex . value = INITIAL_VALUE ;
698
- }
700
+ } ,
701
+ [
702
+ animatedAnimationSource ,
703
+ animatedAnimationState ,
704
+ animatedCurrentIndex ,
705
+ animatedNextPosition ,
706
+ animatedNextPositionIndex ,
707
+ isForcedClosing ,
708
+ ]
699
709
) ;
700
- const animateToPosition : AnimateToPositionType = useWorkletCallback (
710
+ const animateToPosition : AnimateToPositionType = useCallback (
701
711
function animateToPosition (
702
712
position : number ,
703
713
source : ANIMATION_SOURCE ,
704
714
velocity : number = 0 ,
705
715
configs ?: WithTimingConfig | WithSpringConfig
706
716
) {
717
+ 'worklet' ;
707
718
if (
708
719
position === animatedPosition . value ||
709
720
position === undefined ||
@@ -772,8 +783,9 @@ const BottomSheetComponent = forwardRef<BottomSheetMethods, BottomSheetProps>(
772
783
*
773
784
* @param targetPosition position to be set.
774
785
*/
775
- const setToPosition = useWorkletCallback (
786
+ const setToPosition = useCallback (
776
787
function setToPosition ( targetPosition : number ) {
788
+ 'worklet' ;
777
789
if (
778
790
targetPosition === animatedPosition . value ||
779
791
targetPosition === undefined ||
@@ -877,11 +889,12 @@ const BottomSheetComponent = forwardRef<BottomSheetMethods, BottomSheetProps>(
877
889
animatedNextPositionIndex ,
878
890
]
879
891
) ;
880
- const handleSnapToPosition = useWorkletCallback (
892
+ const handleSnapToPosition = useCallback (
881
893
function handleSnapToPosition (
882
894
position : number | string ,
883
895
animationConfigs ?: WithSpringConfig | WithTimingConfig
884
896
) {
897
+ 'worklet' ;
885
898
print ( {
886
899
component : BottomSheet . name ,
887
900
method : handleSnapToPosition . name ,
0 commit comments