/** * This file is originally from `@primer/react` * The original source for this lived in the URL below. * * @see https://github.com/primer/react/blob/216d2a9f57b8acb0701ab4e04a23e057fc325c90/src/hooks/useProvidedRefOrCreate.ts */ import React from 'react'; /** * There are some situations where we only want to create a new ref if one is not provided to a component * or hook as a prop. However, due to the `rules-of-hooks`, we cannot conditionally make a call to `React.useRef` * only in the situations where the ref is not provided as a prop. * This hook aims to encapsulate that logic, so the consumer doesn't need to be concerned with violating `rules-of-hooks`. * @param providedRef The ref to use - if undefined, will use the ref from a call to React.useRef * @type TRef The type of the RefObject which should be created. */ export default function useProvidedRefOrCreate(providedRef?: React.RefObject): React.RefObject;