@@ -27,7 +27,10 @@ import defaultMapStateToPropsFactories from '../connect/mapStateToProps'
27
27
import defaultMergePropsFactories from '../connect/mergeProps'
28
28
29
29
import { createSubscription , Subscription } from '../utils/Subscription'
30
- import { useIsomorphicLayoutEffect } from '../utils/useIsomorphicLayoutEffect'
30
+ import {
31
+ useIsomorphicLayoutEffect ,
32
+ canUseDOM ,
33
+ } from '../utils/useIsomorphicLayoutEffect'
31
34
import shallowEqual from '../utils/shallowEqual'
32
35
33
36
import {
@@ -124,6 +127,7 @@ function subscribeUpdates(
124
127
return
125
128
}
126
129
130
+ // TODO We're currently calling getState ourselves here, rather than letting `uSES` do it
127
131
const latestStoreState = store . getState ( )
128
132
129
133
let newChildProps , error
@@ -157,6 +161,7 @@ function subscribeUpdates(
157
161
childPropsFromStoreUpdate . current = newChildProps
158
162
renderIsScheduled . current = true
159
163
164
+ // TODO This is hacky and not how `uSES` is meant to be used
160
165
// Trigger the React `useSyncExternalStore` subscriber
161
166
additionalSubscribeListener ( )
162
167
}
@@ -597,6 +602,10 @@ function connect<
597
602
? props . store !
598
603
: contextValue ! . store
599
604
605
+ const getServerSnapshot = didStoreComeFromContext
606
+ ? contextValue . getServerState
607
+ : store . getState
608
+
600
609
const childPropsSelector = useMemo ( ( ) => {
601
610
// The child props selector needs the store reference as an input.
602
611
// Re-create this selector whenever the store changes.
@@ -724,7 +733,10 @@ function connect<
724
733
725
734
try {
726
735
actualChildProps = useSyncExternalStore (
736
+ // TODO We're passing through a big wrapper that does a bunch of extra side effects besides subscribing
727
737
subscribeForReact ,
738
+ // TODO This is incredibly hacky. We've already processed the store update and calculated new child props,
739
+ // TODO and we're just passing that through so it triggers a re-render for us rather than relying on `uSES`.
728
740
actualChildPropsSelector ,
729
741
// TODO Need a real getServerSnapshot here
730
742
actualChildPropsSelector
0 commit comments