(adm: ObserverAdministration)
| 23 | } |
| 24 | |
| 25 | function 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 | |
| 35 | export function useObserver<T>(render: () => T, baseComponentName: string = "observed"): T { |
| 36 | if (isUsingStaticRendering()) { |
no outgoing calls
no test coverage detected
searching dependent graphs…