-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
/
Copy pathindex.ts
40 lines (33 loc) · 1.69 KB
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import "./utils/assertEnvironment"
import { unstable_batchedUpdates as batch } from "./utils/reactBatchedUpdates"
import { observerBatching } from "./utils/observerBatching"
import { useDeprecated } from "./utils/utils"
import { useObserver as useObserverOriginal } from "./useObserver"
import { enableStaticRendering } from "./staticRendering"
import { observerFinalizationRegistry } from "./utils/observerFinalizationRegistry"
observerBatching(batch)
export { isUsingStaticRendering, enableStaticRendering } from "./staticRendering"
export { observer, IObserverOptions } from "./observer"
export { Observer } from "./ObserverComponent"
export { useLocalObservable } from "./useLocalObservable"
export { useLocalStore } from "./useLocalStore"
export { useAsObservableSource } from "./useAsObservableSource"
export { observerFinalizationRegistry as _observerFinalizationRegistry }
export const clearTimers = observerFinalizationRegistry["finalizeAllImmediately"] ?? (() => {})
export function useObserver<T>(fn: () => T, baseComponentName: string = "observed"): T {
if ("production" !== process.env.NODE_ENV) {
useDeprecated(
"[mobx-react-lite] 'useObserver(fn)' is deprecated. Use `<Observer>{fn}</Observer>` instead, or wrap the entire component in `observer`."
)
}
return useObserverOriginal(fn, baseComponentName)
}
export { isObserverBatched, observerBatching } from "./utils/observerBatching"
export function useStaticRendering(enable: boolean) {
if ("production" !== process.env.NODE_ENV) {
console.warn(
"[mobx-react-lite] 'useStaticRendering' is deprecated, use 'enableStaticRendering' instead"
)
}
enableStaticRendering(enable)
}