( ref: RefObject<T> | undefined, init: () => R, deps?: DependencyList )
| 215 | } |
| 216 | |
| 217 | export function useImperativeHandle<T, R extends T> ( |
| 218 | ref: RefObject<T> | undefined, |
| 219 | init: () => R, |
| 220 | deps?: DependencyList |
| 221 | ): void { |
| 222 | useLayoutEffect(() => { |
| 223 | if (isFunction(ref)) { |
| 224 | ref(init()) |
| 225 | return () => ref(null) |
| 226 | } else if (!isUndefined(ref)) { |
| 227 | ref.current = init() |
| 228 | return () => { |
| 229 | delete ref.current |
| 230 | } |
| 231 | } |
| 232 | }, isArray(deps) ? deps.concat([ref]) : undefined) |
| 233 | } |
nothing calls this directly
no test coverage detected