Skip to content

Commit

Permalink
[core] Polish useForkRef docs
Browse files Browse the repository at this point in the history
  • Loading branch information
oliviertassinari committed Nov 15, 2024
1 parent 4e26c0b commit 2546f56
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions packages/mui-utils/src/useForkRef/useForkRef.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,19 @@ import setRef from '../setRef';

/**
* Takes an array of refs and returns a new ref which will apply any modification to all of the refs.
*
* This is useful when you want have the ref used in multiple places.
* This is useful when you want to have the ref used in multiple places.
*
* ```tsx
* const newRef = React.useRef<Instance>(null);
* const refFork = useForkRef(newRef, props.ref);
* const rootRef = React.useRef<Instance>(null);
* const refFork = useForkRef(rootRef, props.ref);
*
* return (
* <LogicProvider ref={newRef}>
* <Component ref={refFork} />
* </LogicProvider>
* <Root {...props} ref={refFork} />
* );
* ```
*
* @param {Array<React.Ref<Instance> | undefined>} refs the ref array.
* @returns {React.RefCallback<Instance> | null} the new ref callback.
* @param {Array<React.Ref<Instance> | undefined>} refs The ref array.
* @returns {React.RefCallback<Instance> | null} The new ref callback.
*/
export default function useForkRef<Instance>(
...refs: Array<React.Ref<Instance> | undefined>
Expand Down

0 comments on commit 2546f56

Please sign in to comment.