MCPcopy Create free account
hub / github.com/editablejs/editable / setRef

Function setRef

packages/ui/src/compose-refs.ts:9–15  ·  view source on GitHub ↗

* 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)

Source from the content-addressed store, hash-verified

7 * This utility takes care of different types of refs: callback refs and RefObject(s)
8 */
9function 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

Callers 1

composeRefsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…