Relative Content

Tag Archive for reactjsnext.jshydration

Is there a way to detect when render is part of ‘hydration’?

Context I am writing a library that exposes a useQuery hook: function MyComponent() { const [isLoading, data] = useQuery(“query1”); } useQuery caches data locally. So I could write the following: function useQuery(q) { const [isLoading, data] = useState(() => { if (IndexedDBCache.has(q)) { return [false, IndexedDBCache.get(q)] } return [true]; }); useEffect(() => { // subscribe […]