Saaj UI

composeRefs

A utility to compose multiple refs together

This utility has been copied from the Radix UI library. View the original source here

Installation

npx saaj add composeRefs

Usage

MyComponent.tsx
import React from 'react';
import { View } from 'react-native';
 
import { composeRefs } from '@/utils/composeRefs';
 
export function MyComponent() {
    const ref1 = React.useRef<View>(null);
    const ref2 = React.useRef<View>(null);
    const ref3 = React.useRef<View>(null);
 
    const composedRef = composeRefs(ref1, ref2, ref3);
 
    return (
        <View ref={composedRef}>
            {/* ... */}
        </View>
    )
}

On this page