MCPcopy
hub / github.com/mobxjs/mobx / Provider

Function Provider

packages/mobx-react/src/Provider.tsx:11–27  ·  view source on GitHub ↗
(props: ProviderProps)

Source from the content-addressed store, hash-verified

9}
10
11export function Provider(props: ProviderProps) {
12 const { children, ...stores } = props
13 const parentValue = React.useContext(MobXProviderContext)
14 const mutableProviderRef = React.useRef({ ...parentValue, ...stores })
15 const value = mutableProviderRef.current
16
17 if (__DEV__) {
18 const newValue = { ...value, ...stores } // spread in previous state for the context based stores
19 if (!shallowEqual(value, newValue)) {
20 throw new Error(
21 "MobX Provider: The set of provided stores has changed. See: https://github.com/mobxjs/mobx-react#the-set-of-provided-stores-has-changed-error."
22 )
23 }
24 }
25
26 return <MobXProviderContext.Provider value={value}>{children}</MobXProviderContext.Provider>
27}
28
29Provider.displayName = "MobXProvider"

Callers

nothing calls this directly

Calls 1

shallowEqualFunction · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…