Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/compose/src/hooks/use-copy-to-clipboard/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useRef, useLayoutEffect } from '@wordpress/element';
import type { MutableRefObject, RefCallback } from 'react';
import type { RefObject, RefCallback } from 'react';
import useRefEffect from '../use-ref-effect';

/**
Expand Down Expand Up @@ -60,7 +60,7 @@ export function restoreFocus( trigger: Element ): void {
* @param value
* @return A ref to assign to the target element.
*/
function useUpdatedRef< T >( value: T ): MutableRefObject< T > {
function useUpdatedRef< T >( value: T ): RefObject< T > {
const ref = useRef< T >( value );
useLayoutEffect( () => {
ref.current = value;
Expand Down
4 changes: 2 additions & 2 deletions packages/dataviews/src/hooks/use-infinite-scroll.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import type { View } from '../types';
*/
function captureAnchorElement(
container: HTMLElement,
anchorElementRef: React.MutableRefObject< {
anchorElementRef: React.RefObject< {
posinset: number;
viewportOffset: number;
scrollTop: number;
Expand Down Expand Up @@ -69,7 +69,7 @@ type UseInfiniteScrollProps = {
totalItems: number;
totalPages: number;
};
containerRef: React.MutableRefObject< HTMLDivElement | null >;
containerRef: React.RefObject< HTMLDivElement | null >;
setVisibleEntries?: React.Dispatch< React.SetStateAction< number[] > >;
};

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { ComponentType, MutableRefObject } from 'react';
import type { ComponentType, RefObject } from 'react';
import { getActiveFormat, getActiveObject } from '@wordpress/rich-text';
import type { RichTextValue } from '@wordpress/rich-text';

Expand All @@ -22,7 +22,7 @@ type EditProps = {
onChange: ( value: RichTextValue ) => void;
onFocus: () => void;
value: RichTextValue;
forwardedRef: MutableRefObject< HTMLElement | undefined >;
forwardedRef: RefObject< HTMLElement | undefined >;
isVisible: boolean;
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export function CollaboratorsOverlay( {
{ ( {
containerRef,
}: {
containerRef: React.MutableRefObject< HTMLElement | null >;
containerRef: React.RefObject< HTMLElement | null >;
} ) => (
<Overlay
blockEditorDocument={ containerRef.current?.ownerDocument }
Expand Down
4 changes: 1 addition & 3 deletions packages/grid/src/shared/use-item-exit-animation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,7 @@ type UseItemExitAnimationOptions = {
string,
RectSnapshot
> | null;
childrenCacheRef: React.MutableRefObject<
Map< string, React.ReactElement >
>;
childrenCacheRef: React.RefObject< Map< string, React.ReactElement > >;
};

type UseItemExitAnimationResult = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -967,23 +967,9 @@ function CropperInner(
};
}

// Forward the root element to the consumer's ref.
const setContainerRef = useCallback(
( element: HTMLDivElement | null ) => {
if ( typeof ref === 'function' ) {
ref( element );
} else if ( ref ) {
(
ref as React.MutableRefObject< HTMLDivElement | null >
).current = element;
}
},
[ ref ]
);

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a wrapper around ref that is today completely redundant. In the original #77479 it used to merge two refs (could have been a use of useMergeRefs) but the second ref was since removed. cc @ramonjd


return (
<div
ref={ setContainerRef }
ref={ ref }
className={ clsx(
'wp-media-editor-image-editor',
isDragging && 'wp-media-editor-image-editor--dragging',
Expand Down
Loading