mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-25 06:18:45 +08:00
@@ -2,14 +2,17 @@ import { type DependencyList, type SyntheticEvent } from 'react';
|
||||
|
||||
import { useAsyncCallback } from './affine-async-hooks';
|
||||
|
||||
export const useCatchEventCallback = <E extends SyntheticEvent>(
|
||||
cb: (e: E) => void | Promise<void>,
|
||||
export const useCatchEventCallback = <
|
||||
E extends SyntheticEvent,
|
||||
Args extends any[],
|
||||
>(
|
||||
cb: (e: E, ...args: Args) => void | Promise<void>,
|
||||
deps: DependencyList
|
||||
) => {
|
||||
return useAsyncCallback(
|
||||
async (e: E) => {
|
||||
async (e: E, ...args: Args) => {
|
||||
e.stopPropagation();
|
||||
await cb(e);
|
||||
await cb(e, ...args);
|
||||
},
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
deps
|
||||
|
||||
Reference in New Issue
Block a user