* Set a given ref to a given value * This utility takes care of different types of refs: callback refs and RefObject(s)
(ref: PossibleRef<T>, value: T)
| 7 | * This utility takes care of different types of refs: callback refs and RefObject(s) |
| 8 | */ |
| 9 | function setRef<T>(ref: PossibleRef<T>, value: T) { |
| 10 | if (typeof ref === 'function') { |
| 11 | ref(value) |
| 12 | } else if (ref !== null && ref !== undefined) { |
| 13 | ;(ref as React.MutableRefObject<T>).current = value |
| 14 | } |
| 15 | } |
| 16 | |
| 17 | /** |
| 18 | * A utility to compose multiple refs together |
no outgoing calls
no test coverage detected
searching dependent graphs…