@@ -27,7 +27,10 @@ import defaultMapStateToPropsFactories from '../connect/mapStateToProps'
2727import defaultMergePropsFactories from '../connect/mergeProps'
2828
2929import { createSubscription , Subscription } from '../utils/Subscription'
30- import { useIsomorphicLayoutEffect } from '../utils/useIsomorphicLayoutEffect'
30+ import {
31+ useIsomorphicLayoutEffect ,
32+ canUseDOM ,
33+ } from '../utils/useIsomorphicLayoutEffect'
3134import shallowEqual from '../utils/shallowEqual'
3235
3336import {
@@ -124,6 +127,7 @@ function subscribeUpdates(
124127 return
125128 }
126129
130+ // TODO We're currently calling getState ourselves here, rather than letting `uSES` do it
127131 const latestStoreState = store . getState ( )
128132
129133 let newChildProps , error
@@ -157,6 +161,7 @@ function subscribeUpdates(
157161 childPropsFromStoreUpdate . current = newChildProps
158162 renderIsScheduled . current = true
159163
164+ // TODO This is hacky and not how `uSES` is meant to be used
160165 // Trigger the React `useSyncExternalStore` subscriber
161166 additionalSubscribeListener ( )
162167 }
@@ -597,6 +602,10 @@ function connect<
597602 ? props . store !
598603 : contextValue ! . store
599604
605+ const getServerSnapshot = didStoreComeFromContext
606+ ? contextValue . getServerState
607+ : store . getState
608+
600609 const childPropsSelector = useMemo ( ( ) => {
601610 // The child props selector needs the store reference as an input.
602611 // Re-create this selector whenever the store changes.
@@ -724,7 +733,10 @@ function connect<
724733
725734 try {
726735 actualChildProps = useSyncExternalStore (
736+ // TODO We're passing through a big wrapper that does a bunch of extra side effects besides subscribing
727737 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`.
728740 actualChildPropsSelector ,
729741 // TODO Need a real getServerSnapshot here
730742 actualChildPropsSelector
0 commit comments