UNPKG

1.73 kBPlain TextView Raw
1import "./utils/assertEnvironment"
2
3import { unstable_batchedUpdates as batch } from "./utils/reactBatchedUpdates"
4import { observerBatching } from "./utils/observerBatching"
5import { useDeprecated } from "./utils/utils"
6import { useObserver as useObserverOriginal } from "./useObserver"
7import { enableStaticRendering } from "./staticRendering"
8import { observerFinalizationRegistry } from "./utils/observerFinalizationRegistry"
9
10observerBatching(batch)
11
12export { isUsingStaticRendering, enableStaticRendering } from "./staticRendering"
13export { observer, IObserverOptions } from "./observer"
14export { Observer } from "./ObserverComponent"
15export { useLocalObservable } from "./useLocalObservable"
16export { useLocalStore } from "./useLocalStore"
17export { useAsObservableSource } from "./useAsObservableSource"
18
19export { observerFinalizationRegistry as _observerFinalizationRegistry }
20export const clearTimers = observerFinalizationRegistry["finalizeAllImmediately"] ?? (() => {})
21
22export function useObserver<T>(fn: () => T, baseComponentName: string = "observed"): T {
23 if ("production" !== process.env.NODE_ENV) {
24 useDeprecated(
25 "[mobx-react-lite] 'useObserver(fn)' is deprecated. Use `<Observer>{fn}</Observer>` instead, or wrap the entire component in `observer`."
26 )
27 }
28 return useObserverOriginal(fn, baseComponentName)
29}
30
31export { isObserverBatched, observerBatching } from "./utils/observerBatching"
32
33export function useStaticRendering(enable: boolean) {
34 if ("production" !== process.env.NODE_ENV) {
35 console.warn(
36 "[mobx-react-lite] 'useStaticRendering' is deprecated, use 'enableStaticRendering' instead"
37 )
38 }
39 enableStaticRendering(enable)
40}
41
\No newline at end of file