Skip to content

Commit

Permalink
chore: update examples
Browse files Browse the repository at this point in the history
  • Loading branch information
tannerlinsley committed Jun 24, 2020
1 parent 46b02aa commit f844de8
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 17 deletions.
24 changes: 12 additions & 12 deletions examples/basic/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,6 @@ function App() {
);
}

// This function is not inline to show how query keys are passed to the query function
// Normally, you can inline them if you want.
const getPostById = async (key, id) => {
const { data } = await axios.get(
`https://jsonplaceholder.typicode.com/posts/${id}`
);
return data;
};

function Posts({ setPostId }) {
const { status, data, error, isFetching } = useQuery("posts", async () => {
const { data } = await axios.get(
Expand All @@ -56,7 +47,7 @@ function Posts({ setPostId }) {
) : (
<>
<div>
{data.map(post => (
{data.map((post) => (
<p key={post.id}>
<a
onClick={() => setPostId(post.id)}
Expand All @@ -67,7 +58,7 @@ function Posts({ setPostId }) {
queryCache.getQueryData(["post", post.id])
? {
fontWeight: "bold",
color: "green"
color: "green",
}
: {}
}
Expand All @@ -85,12 +76,21 @@ function Posts({ setPostId }) {
);
}

// This function is not inline to show how query keys are passed to the query function
// Normally, you can inline them if you want.
const getPostById = async (key, id) => {
const { data } = await axios.get(
`https://jsonplaceholder.typicode.com/posts/${id}`
);
return data;
};

function Post({ postId, setPostId }) {
const { status, data, error, isFetching } = useQuery(
["post", postId],
getPostById,
{
enabled: postId
enabled: postId,
}
);

Expand Down
2 changes: 1 addition & 1 deletion examples/playground/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@
"last 1 safari version"
]
}
}
}
13 changes: 9 additions & 4 deletions examples/playground/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2688,9 +2688,9 @@ code-point-at@^1.0.0:
integrity sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c=

codemirror@^5.18.2:
version "5.52.0"
resolved "https://registry.yarnpkg.com/codemirror/-/codemirror-5.52.0.tgz#4dbd6aef7f0e63db826b9a23922f0c03ac75c0a7"
integrity sha512-K2UB6zjscrfME03HeRe/IuOmCeqNpw7PLKGHThYpLbZEuKf+ZoujJPhxZN4hHJS1O7QyzEsV7JJZGxuQWVaFCg==
version "5.55.0"
resolved "https://registry.yarnpkg.com/codemirror/-/codemirror-5.55.0.tgz#23731f641288f202a6858fdc878f3149e0e04363"
integrity sha512-TumikSANlwiGkdF/Blnu/rqovZ0Y3Jh8yy9TqrPbSM0xxSucq3RgnpVDQ+mD9q6JERJEIT2FMuF/fBGfkhIR/g==

collection-visit@^1.0.0:
version "1.0.0"
Expand Down Expand Up @@ -8153,11 +8153,16 @@ react-error-overlay@^6.0.3:
resolved "https://registry.yarnpkg.com/react-error-overlay/-/react-error-overlay-6.0.6.tgz#ac4d9dc4c1b5c536c2c312bf66aa2b09bfa384e2"
integrity sha512-Yzpno3enVzSrSCnnljmr4b/2KUQSMZaPuqmS26t9k4nW7uwJk6STWmH9heNjPuvqUTO3jOSPkHoKgO4+Dw7uIw==

react-is@^16.6.0, react-is@^16.8.1, react-is@^16.8.4:
react-is@^16.6.0, react-is@^16.8.4:
version "16.13.0"
resolved "https://registry.yarnpkg.com/react-is/-/react-is-16.13.0.tgz#0f37c3613c34fe6b37cd7f763a0d6293ab15c527"
integrity sha512-GFMtL0vHkiBv9HluwNZTggSn/sCyEt9n02aM0dSAjGGyqyNlAyftYm4phPxdvCigG15JreC5biwxCgTAJZ7yAA==

react-is@^16.8.1:
version "16.13.1"
resolved "https://registry.yarnpkg.com/react-is/-/react-is-16.13.1.tgz#789729a4dc36de2999dc156dd6c1d9c18cea56a4"
integrity sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==

[email protected]:
version "1.0.2"
resolved "https://registry.yarnpkg.com/react-query-devtools/-/react-query-devtools-1.0.2.tgz#30e3abdb13411af9e28b2a3d0abfea0f56714830"
Expand Down

0 comments on commit f844de8

Please sign in to comment.