Function which returns a componentId
which can be used to identify a component instance by affecting it to its Root sub-component componentId
prop. It can then be passed to the forComponent
prop of other sub-components to associates them to the same component instance.
Notes
createComponentId
must always be called outside of component functions or classes, inside of a file dedicated to component ids and/or React contexts.componentId
must always passed to the Root sub-component of the component instance that is to be identified.componentId
in the virtual DOM can be linked to it.Example
const loginSheetId = createComponentId();
<Sheet.Root componentId={loginSheetId}>
...
<Sheet.Trigger forComponent={loginSheetId} />
...
</Sheet.Root>