Skip to content

Commit

Permalink
replace useState to useMemo
Browse files Browse the repository at this point in the history
  • Loading branch information
torounit committed Sep 28, 2023
1 parent 78ab5e7 commit 821f4d4
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
Expand Up @@ -7,7 +7,7 @@ import { proxyMap } from 'valtio/utils';
/**
* WordPress dependencies
*/
import { useState } from '@wordpress/element';
import { useMemo } from '@wordpress/element';
import isShallowEqual from '@wordpress/is-shallow-equal';

/**
Expand Down Expand Up @@ -109,7 +109,7 @@ function createSlotRegistry(): SlotFillBubblesVirtuallyContext {
export default function SlotFillProvider( {
children,
}: SlotFillProviderProps ) {
const [ registry ] = useState( createSlotRegistry );
const registry = useMemo( 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 { useState } from '@wordpress/element';
import { useMemo } from '@wordpress/element';

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

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

0 comments on commit 821f4d4

Please sign in to comment.