From 821f4d4344f630b337fed4c5beb10eee346899b0 Mon Sep 17 00:00:00 2001 From: Hiroshi Urabe Date: Sat, 9 Sep 2023 09:52:47 +0900 Subject: [PATCH] replace useState to useMemo --- .../src/slot-fill/bubbles-virtually/slot-fill-provider.tsx | 4 ++-- packages/components/src/slot-fill/provider.tsx | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/components/src/slot-fill/bubbles-virtually/slot-fill-provider.tsx b/packages/components/src/slot-fill/bubbles-virtually/slot-fill-provider.tsx index 7cb02192d023b..e93060a5e431a 100644 --- a/packages/components/src/slot-fill/bubbles-virtually/slot-fill-provider.tsx +++ b/packages/components/src/slot-fill/bubbles-virtually/slot-fill-provider.tsx @@ -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'; /** @@ -109,7 +109,7 @@ function createSlotRegistry(): SlotFillBubblesVirtuallyContext { export default function SlotFillProvider( { children, }: SlotFillProviderProps ) { - const [ registry ] = useState( createSlotRegistry ); + const registry = useMemo( createSlotRegistry, [] ); return ( { children } diff --git a/packages/components/src/slot-fill/provider.tsx b/packages/components/src/slot-fill/provider.tsx index 6ed624bab67a3..ea32d7104b498 100644 --- a/packages/components/src/slot-fill/provider.tsx +++ b/packages/components/src/slot-fill/provider.tsx @@ -2,7 +2,7 @@ * WordPress dependencies */ import type { Component } from '@wordpress/element'; -import { useState } from '@wordpress/element'; +import { useMemo } from '@wordpress/element'; /** * Internal dependencies @@ -118,7 +118,7 @@ function createSlotRegistry(): BaseSlotFillContext { } export function SlotFillProvider( { children }: SlotFillProviderProps ) { - const [ contextValue ] = useState( createSlotRegistry ); + const contextValue = useMemo( createSlotRegistry, [] ); return ( { children }