Skip to main content

useDraxId

Generate a stable unique ID for a Drax view. Useful when you need to reference a view's ID from external code.

Import

import { useDraxId } from 'react-native-drax';

Usage

function MyComponent() {
const draxId = useDraxId();

return (
<DraxView id={draxId}>
<Text>My view ID: {draxId}</Text>
</DraxView>
);
}

Return Value

TypeDescription
stringA unique, stable ID string

The ID is generated once and remains stable across re-renders.