@@ -34,7 +34,10 @@ import defaultMapStateToPropsFactories from '../connect/mapStateToProps'
34
34
import defaultMergePropsFactories from '../connect/mergeProps'
35
35
36
36
import { createSubscription , Subscription } from '../utils/Subscription'
37
- import { useIsomorphicLayoutEffect } from '../utils/useIsomorphicLayoutEffect'
37
+ import {
38
+ useIsomorphicLayoutEffect ,
39
+ canUseDOM ,
40
+ } from '../utils/useIsomorphicLayoutEffect'
38
41
import shallowEqual from '../utils/shallowEqual'
39
42
40
43
import {
@@ -123,6 +126,7 @@ function subscribeUpdates(
123
126
return
124
127
}
125
128
129
+ // TODO We're currently calling getState ourselves here, rather than letting `uSES` do it
126
130
const latestStoreState = store . getState ( )
127
131
128
132
let newChildProps , error
@@ -156,6 +160,7 @@ function subscribeUpdates(
156
160
childPropsFromStoreUpdate . current = newChildProps
157
161
renderIsScheduled . current = true
158
162
163
+ // TODO This is hacky and not how `uSES` is meant to be used
159
164
// Trigger the React `useSyncExternalStore` subscriber
160
165
additionalSubscribeListener ( )
161
166
}
@@ -609,6 +614,10 @@ function connect<
609
614
? props . store !
610
615
: contextValue ! . store
611
616
617
+ const getServerSnapshot = didStoreComeFromContext
618
+ ? contextValue . getServerState
619
+ : store . getState
620
+
612
621
const childPropsSelector = useMemo ( ( ) => {
613
622
// The child props selector needs the store reference as an input.
614
623
// Re-create this selector whenever the store changes.
@@ -736,7 +745,10 @@ function connect<
736
745
737
746
try {
738
747
actualChildProps = useSyncExternalStore (
748
+ // TODO We're passing through a big wrapper that does a bunch of extra side effects besides subscribing
739
749
subscribeForReact ,
750
+ // TODO This is incredibly hacky. We've already processed the store update and calculated new child props,
751
+ // TODO and we're just passing that through so it triggers a re-render for us rather than relying on `uSES`.
740
752
actualChildPropsSelector ,
741
753
// TODO Need a real getServerSnapshot here
742
754
actualChildPropsSelector
0 commit comments