MCPcopy Index your code
hub / github.com/mobxjs/mobx / createReaction

Function createReaction

packages/mobx-react-lite/src/useObserver.ts:25–33  ·  view source on GitHub ↗
(adm: ObserverAdministration)

Source from the content-addressed store, hash-verified

23}
24
25function createReaction(adm: ObserverAdministration) {
26 adm.reaction = new Reaction(`observer${adm.name}`, () => {
27 adm.stateVersion = Symbol()
28 // onStoreChange won't be available until the component "mounts".
29 // If state changes in between initial render and mount,
30 // `useSyncExternalStore` should handle that by checking the state version and issuing update.
31 adm.onStoreChange?.()
32 })
33}
34
35export function useObserver<T>(render: () => T, baseComponentName: string = "observed"): T {
36 if (isUsingStaticRendering()) {

Callers 2

subscribeFunction · 0.70
useObserverFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…