Skip to content

[WIP] feat(devtools): add timeline #3841

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions examples/rick-morty/src/Character.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
TableContainer,
TableHead,
TableRow,
Paper
Paper,
} from "@material-ui/core";
import { Link as RouterLink } from "react-router-dom";
import { useParams } from "react-router";
Expand All @@ -17,8 +17,12 @@ import fetch from "./fetch";

function Character() {
const { characterId } = useParams();
const { status, data } = useQuery(`character-${characterId}`, () =>
fetch(`https://rickandmortyapi.com/api/character/${characterId}`)
const { status, data } = useQuery(
`character-${characterId}`,
() => fetch(`https://rickandmortyapi.com/api/character/${characterId}`),
{
cacheTime: 3000,
}
);

if (status === "loading") return <p>Loading...</p>;
Expand Down Expand Up @@ -66,7 +70,7 @@ function Character() {
</TableContainer>
<br />
<Typography variant="h4">Episodes</Typography>
{data.episode.map(episode => {
{data.episode.map((episode) => {
const episodeUrlParts = episode.split("/").filter(Boolean);
const episodeId = episodeUrlParts[episodeUrlParts.length - 1];

Expand Down
10 changes: 7 additions & 3 deletions examples/rick-morty/src/Episode.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ function Episode() {
<Typography variant="body1">{data.air_date}</Typography>
<br />
<Typography variant="h4">Characters</Typography>
{data.characters.map(character => {
{data.characters.map((character) => {
const characterUrlParts = character.split("/").filter(Boolean);
const characterId = characterUrlParts[characterUrlParts.length - 1];
return <Character id={characterId} key={characterId} />;
Expand All @@ -30,8 +30,12 @@ function Episode() {
}

function Character({ id }) {
const { data, status } = useQuery(`character-${id}`, () =>
fetch(`https://rickandmortyapi.com/api/character/${id}`)
const { data, status } = useQuery(
`character-${id}`,
() => fetch(`https://rickandmortyapi.com/api/character/${id}`),
{
cacheTime: 3000,
}
);

if (status === "loading") return <p>Loading...</p>;
Expand Down
11 changes: 8 additions & 3 deletions examples/rick-morty/src/Episodes.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,13 @@ import { useQuery } from "react-query";
import fetch from "./fetch";

export default function Episodes() {
const { data, status } = useQuery("episodes", () =>
fetch("https://rickandmortyapi.com/api/episode")
const { data, status } = useQuery(
"episodes",
() => fetch("https://rickandmortyapi.com/api/episode"),
{
refetchInterval: 3 * 1000,
cacheTime: 2000,
}
);

if (status === "loading") {
Expand All @@ -19,7 +24,7 @@ export default function Episodes() {
return (
<div>
<Typography variant="h2">Episodes</Typography>
{data.results.map(episode => (
{data.results.map((episode) => (
<article key={episode.id}>
<Link component={RouterLink} to={`/episodes/${episode.id}`}>
<Typography variant="h6">
Expand Down
Loading