Skip to content

Commit

Permalink
ESLint: Remove various React Compiler mutation violations (WordPress#…
Browse files Browse the repository at this point in the history
…66327)

Co-authored-by: tyxla <[email protected]>
Co-authored-by: Mamaduka <[email protected]>
  • Loading branch information
3 people authored Oct 22, 2024
1 parent d9e7ee7 commit 8170442
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 12 deletions.
8 changes: 4 additions & 4 deletions packages/block-editor/src/components/iframe/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ function Iframe( {
}, [] );
const { styles = '', scripts = '' } = resolvedAssets;
const [ iframeDocument, setIframeDocument ] = useState();
const initialContainerWidth = useRef( 0 );
const initialContainerWidthRef = useRef( 0 );
const [ bodyClasses, setBodyClasses ] = useState( [] );
const clearerRef = useBlockSelectionClearer();
const [ before, writingFlowRef, after ] = useWritingFlow();
Expand Down Expand Up @@ -243,12 +243,12 @@ function Iframe( {

useEffect( () => {
if ( ! isZoomedOut ) {
initialContainerWidth.current = containerWidth;
initialContainerWidthRef.current = containerWidth;
}
}, [ containerWidth, isZoomedOut ] );

const scaleContainerWidth = Math.max(
initialContainerWidth.current,
initialContainerWidthRef.current,
containerWidth
);

Expand Down Expand Up @@ -345,7 +345,7 @@ function Iframe( {

const maxWidth = 750;
// Note: When we initialize the zoom out when the canvas is smaller (sidebars open),
// initialContainerWidth will be smaller than the full page, and reflow will happen
// initialContainerWidthRef will be smaller than the full page, and reflow will happen
// when the canvas area becomes larger due to sidebars closing. This is a known but
// minor divergence for now.

Expand Down
7 changes: 5 additions & 2 deletions packages/components/src/composite/legacy/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,11 @@ function proxyComposite< C extends Component >(

const { store, ...rest } =
mapLegacyStatePropsToComponentProps( legacyProps );
const props = rest as ComponentProps< C >;
props.id = useInstanceId( store, props.baseId, props.id );
let props = rest as ComponentProps< C >;
props = {
...props,
id: useInstanceId( store, props.baseId, props.id ),
};

Object.entries( propMap ).forEach( ( [ from, to ] ) => {
if ( props.hasOwnProperty( from ) ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ function FooterContent< Item >( {
const [ actionInProgress, setActionInProgress ] = useState< string | null >(
null
);
const footerContent = useRef< JSX.Element | null >( null );
const footerContentRef = useRef< JSX.Element | null >( null );

const bulkActions = useMemo(
() => actions.filter( ( action ) => action.supportsBulk ),
Expand Down Expand Up @@ -306,8 +306,8 @@ function FooterContent< Item >( {
[ actions, selectedItems ]
);
if ( ! actionInProgress ) {
if ( footerContent.current ) {
footerContent.current = null;
if ( footerContentRef.current ) {
footerContentRef.current = null;
}
return renderFooterContent(
data,
Expand All @@ -320,8 +320,8 @@ function FooterContent< Item >( {
setActionInProgress,
onChangeSelection
);
} else if ( ! footerContent.current ) {
footerContent.current = renderFooterContent(
} else if ( ! footerContentRef.current ) {
footerContentRef.current = renderFooterContent(
data,
actions,
getItemId,
Expand All @@ -333,7 +333,7 @@ function FooterContent< Item >( {
onChangeSelection
);
}
return footerContent.current;
return footerContentRef.current;
}

export function BulkActionsFooter() {
Expand Down

0 comments on commit 8170442

Please sign in to comment.