fix: use ref not set init value

This commit is contained in:
Joel
2025-02-08 15:48:08 +08:00
parent 688a461a5b
commit d062519f60
8 changed files with 22 additions and 22 deletions

View File

@ -43,7 +43,7 @@ const defaultSubcribeOption: UseSubcribeOption = {
function useMitt<Events extends _Events>(
mitt?: Emitter<Events>,
): UseMittReturn<Events> {
const emitterRef = useRef<Emitter<Events>>()
const emitterRef = useRef<Emitter<Events> | undefined>(undefined)
if (!emitterRef.current)
emitterRef.current = mitt ?? create<Events>()