MCPcopy
hub / github.com/shadcn-ui/ui / composeRefs

Function composeRefs

packages/react/src/use-render/index.ts:188–206  ·  view source on GitHub ↗
(
  ...refs: Array<React.Ref<T> | undefined>
)

Source from the content-addressed store, hash-verified

186}
187
188function composeRefs<T>(
189 ...refs: Array<React.Ref<T> | undefined>
190): React.RefCallback<T> | undefined {
191 const validRefs = refs.filter(Boolean)
192
193 if (validRefs.length === 0) {
194 return undefined
195 }
196
197 return (value) => {
198 for (const ref of validRefs) {
199 if (typeof ref === "function") {
200 ref(value)
201 } else if (ref) {
202 ref.current = value
203 }
204 }
205 }
206}
207
208export { composeRefs, mergeProps, useRender, type UseRenderComponentProps }

Callers 5

MessageScrollerViewportFunction · 0.90
MessageScrollerContentFunction · 0.90
MessageScrollerItemFunction · 0.90
useRenderFunction · 0.85
mergePropsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected