From 9a210fd2e712399bf89bde1314d679989b503b0f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Burzy=C5=84ski?= Date: Tue, 14 Sep 2021 10:10:09 +0200 Subject: [PATCH] Fixed compatibility with React 18 strict effects --- src/components/Provider.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/Provider.tsx b/src/components/Provider.tsx index cb22b55bf..a85bb7fd6 100644 --- a/src/components/Provider.tsx +++ b/src/components/Provider.tsx @@ -22,7 +22,6 @@ export interface ProviderProps { function Provider({ store, context, children }: ProviderProps) { const contextValue = useMemo(() => { const subscription = createSubscription(store) - subscription.onStateChange = subscription.notifyNestedSubs return { store, subscription, @@ -33,6 +32,7 @@ function Provider({ store, context, children }: ProviderProps) { useIsomorphicLayoutEffect(() => { const { subscription } = contextValue + subscription.onStateChange = subscription.notifyNestedSubs subscription.trySubscribe() if (previousState !== store.getState()) {