Skip to content

Commit f419fb5

Browse files
committed
fix: out-dated worklet handler
1 parent a653308 commit f419fb5

1 file changed

Lines changed: 12 additions & 8 deletions

File tree

src/hooks/index.ts

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { useEffect, useLayoutEffect } from "react";
2-
import { useEvent } from "react-native-reanimated";
2+
import { useEvent, useHandler } from "react-native-reanimated";
33

44
import { AndroidSoftInputModes } from "../constants";
55
import { useKeyboardContext } from "../context";
@@ -13,7 +13,6 @@ import type {
1313
KeyboardHandler,
1414
NativeEvent,
1515
} from "../types";
16-
import type { DependencyList } from "react";
1716

1817
/**
1918
* Hook that sets the Android soft input mode to adjust resize on mount and
@@ -114,10 +113,12 @@ export const useReanimatedKeyboardAnimation = (): ReanimatedContext => {
114113
*/
115114
export function useGenericKeyboardHandler(
116115
handler: KeyboardHandler,
117-
deps?: DependencyList,
116+
deps?: unknown[],
118117
) {
119118
const context = useKeyboardContext();
120119

120+
const { doDependenciesDiffer } = useHandler(handler, deps);
121+
121122
const eventHandler = useEvent<NativeEvent>(
122123
(event) => {
123124
"worklet";
@@ -144,6 +145,7 @@ export function useGenericKeyboardHandler(
144145
"onKeyboardMoveEnd",
145146
"onKeyboardMoveInteractive",
146147
],
148+
doDependenciesDiffer,
147149
);
148150

149151
useLayoutEffect(() => {
@@ -184,10 +186,7 @@ export function useGenericKeyboardHandler(
184186
* }
185187
* ```
186188
*/
187-
export function useKeyboardHandler(
188-
handler: KeyboardHandler,
189-
deps?: DependencyList,
190-
) {
189+
export function useKeyboardHandler(handler: KeyboardHandler, deps?: unknown[]) {
191190
useResizeMode();
192191
useGenericKeyboardHandler(handler, deps);
193192
}
@@ -259,10 +258,14 @@ export function useReanimatedFocusedInput() {
259258
*/
260259
export function useFocusedInputHandler(
261260
handler: FocusedInputHandler,
262-
deps?: DependencyList,
261+
deps?: unknown[],
263262
) {
264263
const context = useKeyboardContext();
265264

265+
// TODO: fix it later
266+
// @ts-expect-error fix it later
267+
const { doDependenciesDiffer } = useHandler(handler, deps);
268+
266269
const eventHandler = useEvent<
267270
FocusedInputSelectionChangedEvent | FocusedInputTextChangedEvent
268271
>(
@@ -278,6 +281,7 @@ export function useFocusedInputHandler(
278281
}
279282
},
280283
["onFocusedInputTextChanged", "onFocusedInputSelectionChanged"],
284+
doDependenciesDiffer,
281285
);
282286

283287
useLayoutEffect(() => {

0 commit comments

Comments
 (0)