UNPKG

1.23 kBJavaScriptView Raw
1var __read = (this && this.__read) || function (o, n) {
2 var m = typeof Symbol === "function" && o[Symbol.iterator];
3 if (!m) return o;
4 var i = m.call(o), r, ar = [], e;
5 try {
6 while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
7 }
8 catch (error) { e = { error: error }; }
9 finally {
10 try {
11 if (r && !r.done && (m = i["return"])) m.call(i);
12 }
13 finally { if (e) throw e.error; }
14 }
15 return ar;
16};
17import { useDeprecated } from "./utils/utils";
18import { observable, runInAction } from "mobx";
19import { useState } from "react";
20export function useAsObservableSource(current) {
21 if ("production" !== process.env.NODE_ENV)
22 useDeprecated("[mobx-react-lite] 'useAsObservableSource' is deprecated, please store the values directly in an observable, for example by using 'useLocalObservable', and sync future updates using 'useEffect' when needed. See the README for examples.");
23 var _a = __read(useState(function () { return observable(current, {}, { deep: false }); }), 1), res = _a[0];
24 runInAction(function () {
25 Object.assign(res, current);
26 });
27 return res;
28}
29//# sourceMappingURL=useAsObservableSource.js.map
\No newline at end of file