UNPKG

one

Version:

One is a React framework for web, iOS, and Android apps.

30 lines (27 loc) • 792 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