Skip to content

Commit

Permalink
Bring dev mode checks underneath process.env.NODE_ENV references
Browse files Browse the repository at this point in the history
- This was done to ensure that the remaining traces of dev mode checks will not be present in the `'production'` build.
  • Loading branch information
aryaemami59 committed Nov 11, 2024
1 parent 912bdce commit 5f64c8b
Showing 1 changed file with 20 additions and 12 deletions.
32 changes: 20 additions & 12 deletions src/components/Provider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,24 +54,32 @@ export interface ProviderProps<
children: ReactNode
}

function Provider<A extends Action<string> = UnknownAction, S = unknown>({
store,
context,
children,
serverState,
stabilityCheck = 'once',
identityFunctionCheck = 'once',
}: ProviderProps<A, S>) {
function Provider<A extends Action<string> = UnknownAction, S = unknown>(
providerProps: ProviderProps<A, S>,
) {
const { children, context, serverState, store } = providerProps

const contextValue = React.useMemo(() => {
const subscription = createSubscription(store)
return {

const baseContextValue = {
store,
subscription,
getServerState: serverState ? () => serverState : undefined,
stabilityCheck,
identityFunctionCheck,
}
}, [store, serverState, stabilityCheck, identityFunctionCheck])

if (process.env.NODE_ENV === 'production') {
return baseContextValue
} else {
const { identityFunctionCheck = 'once', stabilityCheck = 'once' } =
providerProps

return /* @__PURE__ */ Object.assign(baseContextValue, {
stabilityCheck,
identityFunctionCheck,
})
}
}, [store, serverState])

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

Expand Down

0 comments on commit 5f64c8b

Please sign in to comment.