Skip to content
Merged
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
Prev Previous commit
Next Next commit
Switch to useLayoutEffect
  • Loading branch information
talldan committed Aug 22, 2022
commit 07ff4b07332d8ef872a6c0b128c89c639716b9dc
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*/
import { useRefEffect } from '@wordpress/compose';
import { useSelect } from '@wordpress/data';
import { useCallback, useEffect, useState } from '@wordpress/element';
import { useCallback, useLayoutEffect, useState } from '@wordpress/element';

/**
* Internal dependencies
Expand Down Expand Up @@ -87,10 +87,10 @@ export default function useBlockToolbarPopoverProps( {
// Update props when the block is moved. This also ensures the props are
// correct on initial mount, and when the selected block or content element
// changes (since the callback ref will update).
useEffect( updateProps, [ blockIndex, updateProps ] );
useLayoutEffect( updateProps, [ blockIndex, updateProps ] );

// Update props when the viewport is resized or the block is resized.
useEffect( () => {
useLayoutEffect( () => {
if ( ! contentElement || ! selectedBlockElement ) {
return;
}
Expand Down