Skip to content

Commit

Permalink
Block Editor: Fix React Complier error for 'useEventListeners' (WordP…
Browse files Browse the repository at this point in the history
…ress#66495)


Co-authored-by: Mamaduka <[email protected]>
Co-authored-by: tyxla <[email protected]>
  • Loading branch information
3 people authored Oct 29, 2024
1 parent b5cd6e9 commit ffba007
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* WordPress dependencies
*/
import { useMemo, useRef } from '@wordpress/element';
import { useMemo, useRef, useInsertionEffect } from '@wordpress/element';
import { useRefEffect } from '@wordpress/compose';

/**
Expand Down Expand Up @@ -35,7 +35,9 @@ const allEventListeners = [

export function useEventListeners( props ) {
const propsRef = useRef( props );
propsRef.current = props;
useInsertionEffect( () => {
propsRef.current = props;
} );
const refEffects = useMemo(
() => allEventListeners.map( ( refEffect ) => refEffect( propsRef ) ),
[ propsRef ]
Expand Down

0 comments on commit ffba007

Please sign in to comment.