Skip to content

Commit d4dfe8d

Browse files
simplify loops
1 parent c556cee commit d4dfe8d

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

src/hooks/useRecognizers.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,16 +39,18 @@ export default function useRecognizers<Config extends Partial<GenericOptions>>(
3939
*/
4040
const bind = (...args: any[]) => {
4141
current.resetBindings()
42-
classes.forEach(RecognizerClass => {
42+
for (let RecognizerClass of classes) {
4343
new RecognizerClass(current, args).addBindings()
44-
})
44+
}
4545

46+
// we also add event bindings for native handlers
4647
if (controller.nativeRefs) {
47-
// we also add event bindings for native handlers
48-
Object.entries(controller.nativeRefs).forEach(([eventName, fn]) => {
49-
// we're cheating when it comes to event type :(
50-
current.addBindings(eventName as ReactEventHandlerKey, fn as Fn)
51-
})
48+
for (let eventName in controller.nativeRefs)
49+
current.addBindings(
50+
eventName as ReactEventHandlerKey,
51+
// @ts-ignore we're cheating when it comes to event type :(
52+
controller.nativeRefs[eventName] as Fn
53+
)
5254
}
5355

5456
return current.getBind() as HookReturnType<Config>

0 commit comments

Comments
 (0)