Skip to content

Commit

Permalink
SlotFills: Use state for registry initialization (#61802)
Browse files Browse the repository at this point in the history
Co-authored-by: Mamaduka <[email protected]>
Co-authored-by: ellatrix <[email protected]>
  • Loading branch information
3 people authored May 21, 2024
1 parent 68b2d30 commit c706195
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* WordPress dependencies
*/
import { useMemo } from '@wordpress/element';
import { useState } from '@wordpress/element';
import isShallowEqual from '@wordpress/is-shallow-equal';
import { observableMap } from '@wordpress/compose';

Expand Down Expand Up @@ -98,7 +98,7 @@ function createSlotRegistry(): SlotFillBubblesVirtuallyContext {
export default function SlotFillProvider( {
children,
}: SlotFillProviderProps ) {
const registry = useMemo( createSlotRegistry, [] );
const [ registry ] = useState( createSlotRegistry );
return (
<SlotFillContext.Provider value={ registry }>
{ children }
Expand Down
4 changes: 2 additions & 2 deletions packages/components/src/slot-fill/provider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* WordPress dependencies
*/
import type { Component } from '@wordpress/element';
import { useMemo } from '@wordpress/element';
import { useState } from '@wordpress/element';

/**
* Internal dependencies
Expand Down Expand Up @@ -118,7 +118,7 @@ function createSlotRegistry(): BaseSlotFillContext {
}

export function SlotFillProvider( { children }: SlotFillProviderProps ) {
const contextValue = useMemo( createSlotRegistry, [] );
const [ contextValue ] = useState( createSlotRegistry );
return (
<SlotFillContext.Provider value={ contextValue }>
{ children }
Expand Down

1 comment on commit c706195

@github-actions
Copy link

Choose a reason for hiding this comment

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

Flaky tests detected in c706195.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/9169150893
📝 Reported issues:

Please sign in to comment.