UNPKG

one

Version:

One is a new React Framework that makes Vite serve both native and web.

30 lines (29 loc) 851 B
import { useLayoutEffect, useState } from "react"; function useQuery(q) { var enable = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : true; var queryImpl = q; var [snapshot, setSnapshot] = useState(void 0); var [, setView] = useState(void 0); useLayoutEffect(function () { if (enable) { var view = q.materialize(); setView(view); var unsubscribe = view.addListener(function (snapshot2) { setSnapshot(structuredClone(snapshot2)); }); view.hydrate(); return function () { unsubscribe(); view.destroy(); }; } setSnapshot(queryImpl.singular ? void 0 : []); setView(void 0); return function () {}; }, // [JSON.stringify(enable ? q.ast : null)]); return snapshot; } export { useQuery }; //# sourceMappingURL=useQueryZero.native.js.map