Skip to content

Instantly share code, notes, and snippets.

@oney
Last active July 2, 2022 05:13
Show Gist options
  • Select an option

  • Save oney/ba9ee3a197f107b97b4e2a08772d26c3 to your computer and use it in GitHub Desktop.

Select an option

Save oney/ba9ee3a197f107b97b4e2a08772d26c3 to your computer and use it in GitHub Desktop.

Revisions

  1. oney revised this gist Jul 2, 2022. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion app.jsx
    Original file line number Diff line number Diff line change
    @@ -1,10 +1,11 @@
    import { useQuery } from "react-query";
    import { BrowserRouter, Route, Routes } from "react-router-dom";
    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>
  2. oney revised this gist Jul 2, 2022. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion app.jsx
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,5 @@
    import { BrowserRouter, Route, Routes, useQuery } from "react-query";
    import { useQuery } from "react-query";
    import { BrowserRouter, Route, Routes } from "react-router-dom";

    export default function App() {
    return (
  3. oney revised this gist Jul 2, 2022. 1 changed file with 11 additions and 1 deletion.
    12 changes: 11 additions & 1 deletion app.jsx
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,14 @@
    import { useQuery } from "react-query";
    import { BrowserRouter, Route, Routes, useQuery } from "react-query";

    export default function App() {
    return (
    <BrowserRouter>
    <Routes>
    <Route path="a" element={<A />} />
    </Routes>
    </BrowserRouter>
    );
    }

    function A() {
    const { isLoading, data } = useQuery("A", () => fetchA());
  4. oney created this gist Jul 2, 2022.
    19 changes: 19 additions & 0 deletions app.jsx
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,19 @@
    import { useQuery } from "react-query";

    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>;
    }