Skip to content

Instantly share code, notes, and snippets.

@oney
Last active July 2, 2022 05:13
Show Gist options
  • Save oney/ba9ee3a197f107b97b4e2a08772d26c3 to your computer and use it in GitHub Desktop.
Save oney/ba9ee3a197f107b97b4e2a08772d26c3 to your computer and use it in GitHub Desktop.
import { useQuery } from "react-query";
import { BrowserRouter, Link, Route, Routes } from "react-router-dom";
export default function App() {
return (
<BrowserRouter>
<Routes>
<Link to="/a">A</Link>
<Route path="a" element={<A />} />
</Routes>
</BrowserRouter>
);
}
function A() {
const { isLoading, data } = useQuery("A", () => fetchA());
if (isLoading) return <p>Loading</p>;
return <div> {data} <B/> </div>;
}
function B() {
const { isLoading, data } = useQuery("B", () => fetchB());
if (isLoading) return <p>Loading</p>;
return <div> {data} <C/> </div>;
}
function C() {
const { isLoading, data } = useQuery("C", () => fetchC());
if (isLoading) return <p>Loading</p>;
return <div>{data}</div>;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment