Skip to content

Commit 5f64c8b

Browse files
committed
Bring dev mode checks underneath process.env.NODE_ENV references
- This was done to ensure that the remaining traces of dev mode checks will not be present in the `'production'` build.
1 parent 912bdce commit 5f64c8b

File tree

1 file changed

+20
-12
lines changed

1 file changed

+20
-12
lines changed

Diff for: src/components/Provider.tsx

+20-12
Original file line numberDiff line numberDiff line change
@@ -54,24 +54,32 @@ export interface ProviderProps<
5454
children: ReactNode
5555
}
5656

57-
function Provider<A extends Action<string> = UnknownAction, S = unknown>({
58-
store,
59-
context,
60-
children,
61-
serverState,
62-
stabilityCheck = 'once',
63-
identityFunctionCheck = 'once',
64-
}: ProviderProps<A, S>) {
57+
function Provider<A extends Action<string> = UnknownAction, S = unknown>(
58+
providerProps: ProviderProps<A, S>,
59+
) {
60+
const { children, context, serverState, store } = providerProps
61+
6562
const contextValue = React.useMemo(() => {
6663
const subscription = createSubscription(store)
67-
return {
64+
65+
const baseContextValue = {
6866
store,
6967
subscription,
7068
getServerState: serverState ? () => serverState : undefined,
71-
stabilityCheck,
72-
identityFunctionCheck,
7369
}
74-
}, [store, serverState, stabilityCheck, identityFunctionCheck])
70+
71+
if (process.env.NODE_ENV === 'production') {
72+
return baseContextValue
73+
} else {
74+
const { identityFunctionCheck = 'once', stabilityCheck = 'once' } =
75+
providerProps
76+
77+
return /* @__PURE__ */ Object.assign(baseContextValue, {
78+
stabilityCheck,
79+
identityFunctionCheck,
80+
})
81+
}
82+
}, [store, serverState])
7583

7684
const previousState = React.useMemo(() => store.getState(), [store])
7785

0 commit comments

Comments
 (0)