one
Version:
One is a new React Framework that makes Vite serve both native and web.
20 lines (19 loc) • 1.01 kB
JavaScript
import { useRef } from "react";
import { getServerContext } from "../vite/one-server-only.native.js";
import { getQueryKey } from "./getQueryKey.native.js";
import { resolveZeroQuery } from "./resolveQuery.native.js";
import { useQuery as useQueryZero } from "./useQueryZero.native.js";
var _getServerContext;
var clientInitialData = (_getServerContext = getServerContext()) === null || _getServerContext === void 0 ? void 0 : _getServerContext.postRenderData;
var serverQueryData = {};
globalThis["__vxrnServerData__"] = serverQueryData;
var useQuery = function (query) {
var snapshot = useQueryZero(query, arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : true);
var queryIdRef = useRef(void 0);
if (query && !queryIdRef.current) queryIdRef.current = getQueryKey(query);
var queryId = queryIdRef.current || "";
if (clientInitialData && !snapshot) return clientInitialData[queryId] || [];
return snapshot || [];
};
export { useQuery };
//# sourceMappingURL=useQuery.native.js.map