Skip to content

Commit

Permalink
Update useMergedRefs
Browse files Browse the repository at this point in the history
  • Loading branch information
joel-jeremy committed Apr 11, 2024
1 parent a1e7e6c commit e0dd586
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,9 @@ const AmountInput = memo(function AmountInput({
const inputRef = useRef<HTMLInputElement>();
const [hideFraction = false] = useLocalPref('hideFraction');

// Need to update useMergedRefs to support Ref.
const mergedInputRef = useMergedRefs<HTMLInputElement>(
props.inputRef as MutableRefObject<HTMLInputElement>,
inputRef as MutableRefObject<HTMLInputElement>,
props.inputRef,
inputRef,
);

const initialValue = Math.abs(props.value);
Expand Down
8 changes: 7 additions & 1 deletion packages/desktop-client/src/hooks/useMergedRefs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,13 @@ import { useCallback } from 'react';
import type { MutableRefObject, Ref, RefCallback } from 'react';

export function useMergedRefs<T>(
...refs: (RefCallback<T> | MutableRefObject<T> | Ref<T> | null | undefined)[]
...refs: (
| RefCallback<T | null | undefined>
| MutableRefObject<T | null | undefined>
| Ref<T | null | undefined>
| null
| undefined
)[]
): Ref<T> {
return useCallback(
(value: T) => {
Expand Down

0 comments on commit e0dd586

Please sign in to comment.