Skip to content

Commit

Permalink
Fixed compatibility with React 18 strict effects
Browse files Browse the repository at this point in the history
  • Loading branch information
Andarist committed Sep 14, 2021
1 parent d859c23 commit 9a210fd
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/components/Provider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ export interface ProviderProps<A extends Action = AnyAction> {
function Provider({ store, context, children }: ProviderProps) {
const contextValue = useMemo(() => {
const subscription = createSubscription(store)
subscription.onStateChange = subscription.notifyNestedSubs
return {
store,
subscription,
Expand All @@ -33,6 +32,7 @@ function Provider({ store, context, children }: ProviderProps) {

useIsomorphicLayoutEffect(() => {
const { subscription } = contextValue
subscription.onStateChange = subscription.notifyNestedSubs
subscription.trySubscribe()

if (previousState !== store.getState()) {
Expand Down

0 comments on commit 9a210fd

Please sign in to comment.