hooks icon indicating copy to clipboard operation
hooks copied to clipboard

useLatest useUnmountedRef 类型带有 null

Open 867068988 opened this issue 6 months ago • 5 comments

useLatest useUnmountedRef 的结果类型不应该带有 null

867068988 avatar Jul 14 '25 01:07 867068988

这个是根据传进来的数据类型推导的,不太明白你的问题

crazylxr avatar Jul 14 '25 01:07 crazylxr

传进来的数据类型 联合了 null

867068988 avatar Jul 14 '25 02:07 867068988

原来是 MutableRefObject<T>,是符合预期的,现在是 RefObject<T>,自动联合了 null

867068988 avatar Jul 14 '25 02:07 867068988

最好是这样: interface CusRefObject<T> { readonly current: T; }

867068988 avatar Jul 14 '25 02:07 867068988

Image 查了下 是react 19 改的类型 ....

adolfheir avatar Aug 28 '25 02:08 adolfheir