Skip to content

Commit dfaec13

Browse files
authored
fix(#2356): added missing dependencies to callback hooks (#2382)
* fix(#2356): added missing dependencies to callback hooks * Update BottomSheet.tsx
1 parent e31f0f0 commit dfaec13

File tree

5 files changed

+110
-56
lines changed

5 files changed

+110
-56
lines changed

src/components/bottomSheet/BottomSheet.tsx

Lines changed: 86 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -605,7 +605,16 @@ const BottomSheetComponent = forwardRef<BottomSheet, BottomSheetProps>(
605605
animatedNextPositionIndex.value = INITIAL_VALUE;
606606
animatedContainerHeightDidChange.value = false;
607607
},
608-
[]
608+
[
609+
animatedAnimationSource,
610+
animatedAnimationState,
611+
animatedContainerHeightDidChange,
612+
animatedCurrentIndex,
613+
animatedNextPosition,
614+
animatedNextPositionIndex,
615+
isAnimatedOnMount,
616+
isForcedClosing,
617+
]
609618
);
610619
const animateToPosition: AnimateToPositionType = useCallback(
611620
function animateToPosition(
@@ -690,50 +699,69 @@ const BottomSheetComponent = forwardRef<BottomSheet, BottomSheetProps>(
690699
keyboardBehavior,
691700
_providedAnimationConfigs,
692701
_providedOverrideReduceMotion,
702+
animateToPositionCompleted,
703+
animatedAnimationSource,
704+
animatedAnimationState,
705+
animatedKeyboardHeightInContainer,
706+
animatedKeyboardState,
707+
animatedNextPosition,
708+
animatedNextPositionIndex,
709+
animatedPosition,
710+
animatedSnapPoints,
711+
stopAnimation,
693712
]
694713
);
695714
/**
696715
* Set to position without animation.
697716
*
698717
* @param targetPosition position to be set.
699718
*/
700-
const setToPosition = useCallback(function setToPosition(
701-
targetPosition: number
702-
) {
703-
'worklet';
704-
if (
705-
targetPosition === animatedPosition.value ||
706-
targetPosition === undefined ||
707-
(animatedAnimationState.value === ANIMATION_STATE.RUNNING &&
708-
targetPosition === animatedNextPosition.value)
709-
) {
710-
return;
711-
}
719+
const setToPosition = useCallback(
720+
function setToPosition(targetPosition: number) {
721+
'worklet';
722+
if (
723+
targetPosition === animatedPosition.value ||
724+
targetPosition === undefined ||
725+
(animatedAnimationState.value === ANIMATION_STATE.RUNNING &&
726+
targetPosition === animatedNextPosition.value)
727+
) {
728+
return;
729+
}
712730

713-
if (__DEV__) {
714-
runOnJS(print)({
715-
component: BottomSheet.name,
716-
method: setToPosition.name,
717-
params: {
718-
currentPosition: animatedPosition.value,
719-
targetPosition,
720-
},
721-
});
722-
}
731+
if (__DEV__) {
732+
runOnJS(print)({
733+
component: 'BottomSheet',
734+
method: setToPosition.name,
735+
params: {
736+
currentPosition: animatedPosition.value,
737+
targetPosition,
738+
},
739+
});
740+
}
723741

724-
/**
725-
* store next position
726-
*/
727-
animatedNextPosition.value = targetPosition;
728-
animatedNextPositionIndex.value =
729-
animatedSnapPoints.value.indexOf(targetPosition);
742+
/**
743+
* store next position
744+
*/
745+
animatedNextPosition.value = targetPosition;
746+
animatedNextPositionIndex.value =
747+
animatedSnapPoints.value.indexOf(targetPosition);
730748

731-
stopAnimation();
749+
stopAnimation();
732750

733-
// set values
734-
animatedPosition.value = targetPosition;
735-
animatedContainerHeightDidChange.value = false;
736-
}, []);
751+
// set values
752+
animatedPosition.value = targetPosition;
753+
animatedContainerHeightDidChange.value = false;
754+
},
755+
[
756+
animatedAnimationState,
757+
animatedContainerHeightDidChange,
758+
animatedNextPosition,
759+
animatedNextPositionIndex,
760+
animatedPosition,
761+
animatedSnapPoints,
762+
stopAnimation,
763+
]
764+
);
737765
//#endregion
738766

739767
//#region private methods
@@ -845,6 +873,8 @@ const BottomSheetComponent = forwardRef<BottomSheet, BottomSheetProps>(
845873
keyboardBehavior,
846874
keyboardBlurBehavior,
847875
_providedIndex,
876+
android_keyboardInputMode,
877+
animatedClosedPosition,
848878
]
849879
);
850880

@@ -969,7 +999,25 @@ const BottomSheetComponent = forwardRef<BottomSheet, BottomSheetProps>(
969999
animationConfigs
9701000
);
9711001
},
972-
[getEvaluatedPosition, animateToPosition, setToPosition, reduceMotion]
1002+
[
1003+
getEvaluatedPosition,
1004+
animateToPosition,
1005+
setToPosition,
1006+
reduceMotion,
1007+
animateOnMount,
1008+
animatedAnimationState,
1009+
animatedClosedPosition,
1010+
animatedContainerHeightDidChange,
1011+
animatedCurrentIndex,
1012+
animatedIndex,
1013+
animatedNextPositionIndex,
1014+
animatedPosition,
1015+
animatedSnapPoints,
1016+
isAnimatedOnMount,
1017+
isForcedClosing,
1018+
isInTemporaryPosition,
1019+
isLayoutCalculated,
1020+
]
9731021
);
9741022
//#endregion
9751023

@@ -1039,7 +1087,7 @@ const BottomSheetComponent = forwardRef<BottomSheet, BottomSheetProps>(
10391087
'worklet';
10401088
if (__DEV__) {
10411089
print({
1042-
component: BottomSheet.name,
1090+
component: 'BottomSheet',
10431091
method: handleSnapToPosition.name,
10441092
params: {
10451093
position,
@@ -1083,12 +1131,11 @@ const BottomSheetComponent = forwardRef<BottomSheet, BottomSheetProps>(
10831131
},
10841132
[
10851133
animateToPosition,
1086-
bottomInset,
1087-
topInset,
10881134
isLayoutCalculated,
10891135
isForcedClosing,
10901136
animatedContainerHeight,
1091-
animatedPosition,
1137+
animatedNextPosition,
1138+
isInTemporaryPosition,
10921139
]
10931140
);
10941141
// biome-ignore lint/correctness/useExhaustiveDependencies(BottomSheet.name): used for debug only

src/hooks/useGestureEventsHandlersDefault.tsx

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
import { useCallback } from 'react';
22
import { Keyboard, Platform } from 'react-native';
3-
import {
4-
runOnJS,
5-
useSharedValue,
6-
} from 'react-native-reanimated';
3+
import { runOnJS, useSharedValue } from 'react-native-reanimated';
74
import {
85
ANIMATION_SOURCE,
96
GESTURE_SOURCE,
@@ -110,6 +107,7 @@ export const useGestureEventsHandlersDefault: GestureEventsHandlersHookType =
110107
animatedPosition,
111108
animatedKeyboardState,
112109
animatedScrollableContentOffsetY,
110+
context,
113111
]
114112
);
115113
const handleOnChange: GestureEventHandlerCallbackType = useCallback(
@@ -267,6 +265,7 @@ export const useGestureEventsHandlersDefault: GestureEventsHandlersHookType =
267265
animatedPosition,
268266
animatedScrollableType,
269267
animatedScrollableContentOffsetY,
268+
context,
270269
]
271270
);
272271
const handleOnEnd: GestureEventHandlerCallbackType = useCallback(
@@ -401,17 +400,17 @@ export const useGestureEventsHandlersDefault: GestureEventsHandlersHookType =
401400
animatedSnapPoints,
402401
animatedScrollableContentOffsetY,
403402
animateToPosition,
403+
context,
404404
]
405405
);
406406

407-
const handleOnFinalize: GestureEventHandlerCallbackType =
408-
useCallback(
409-
function handleOnFinalize() {
410-
'worklet';
411-
resetContext(context);
412-
},
413-
[context]
414-
);
407+
const handleOnFinalize: GestureEventHandlerCallbackType = useCallback(
408+
function handleOnFinalize() {
409+
'worklet';
410+
resetContext(context);
411+
},
412+
[context]
413+
);
415414
//#endregion
416415

417416
return {

src/hooks/useGestureEventsHandlersDefault.web.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
import { useCallback } from 'react';
22
import { Keyboard, Platform } from 'react-native';
3-
import {
4-
runOnJS,
5-
useSharedValue,
6-
} from 'react-native-reanimated';
3+
import { runOnJS, useSharedValue } from 'react-native-reanimated';
74
import {
85
ANIMATION_SOURCE,
96
GESTURE_SOURCE,
@@ -94,6 +91,7 @@ export const useGestureEventsHandlersDefault = () => {
9491
animatedPosition,
9592
animatedKeyboardState,
9693
animatedScrollableContentOffsetY,
94+
context,
9795
]
9896
);
9997
const handleOnChange: GestureEventHandlerCallbackType = useCallback(
@@ -249,6 +247,7 @@ export const useGestureEventsHandlersDefault = () => {
249247
animatedPosition,
250248
animatedScrollableType,
251249
animatedScrollableContentOffsetY,
250+
context,
252251
]
253252
);
254253
const handleOnEnd: GestureEventHandlerCallbackType = useCallback(
@@ -383,6 +382,7 @@ export const useGestureEventsHandlersDefault = () => {
383382
animatedSnapPoints,
384383
animatedScrollableContentOffsetY,
385384
animateToPosition,
385+
context,
386386
]
387387
);
388388
const handleOnFinalize: GestureEventHandlerCallbackType = useCallback(

src/hooks/useKeyboard.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,14 @@ export const useKeyboard = () => {
7575
keyboardState.value = state;
7676
temporaryCachedKeyboardEvent.value = [];
7777
},
78-
[]
78+
[
79+
keyboardAnimationDuration,
80+
keyboardAnimationEasing,
81+
keyboardHeight,
82+
keyboardState,
83+
shouldHandleKeyboardEvents,
84+
temporaryCachedKeyboardEvent,
85+
]
7986
);
8087
//#endregion
8188

src/hooks/useScrollEventsHandlersDefault.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ export const useScrollEventsHandlersDefault: ScrollEventsHandlersHookType = (
6666
scrollableContentOffsetY,
6767
animatedScrollableState,
6868
animatedSheetState,
69+
animatedHandleGestureState,
6970
]
7071
);
7172
const handleOnBeginDrag: ScrollEventHandlerCallbackType<ScrollEventContextType> =

0 commit comments

Comments
 (0)