Skip to content

Commit

Permalink
- fix mistake in refetching-queries-with-different-data
Browse files Browse the repository at this point in the history
Reviewed By: captbaritone

Differential Revision: D68355773

fbshipit-source-id: ba1724a951ab5e0fb56a09ef54eed18040adc497
  • Loading branch information
lynnshaoyu authored and facebook-github-bot committed Jan 24, 2025
1 parent efd2a0a commit 61c7de9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ function App(props: Props) {
const refetch = useCallback(() => {
if (isRefetching) { return; }
setIsRefetching(true);
const variables = { id: 'different-id' };

// fetchQuery will fetch the query and write
// the data to the Relay store. This will ensure
Expand All @@ -146,7 +147,7 @@ function App(props: Props) {
// At this point the data for the query should
// be cached, so we use the 'store-only'
// fetchPolicy to avoid suspending.
loadQuery({id: 'different-id'}, {fetchPolicy: 'store-only'});
loadQuery(variables, {fetchPolicy: 'store-only'});
},
error: () => {
setIsRefetching(false);
Expand Down Expand Up @@ -292,6 +293,7 @@ function App(props: Props) {
const refetch = useCallback(() => {
if (isRefreshing) { return; }
setIsRefreshing(true);
const variables = { id: 'different-id' };

// fetchQuery will fetch the query and write
// the data to the Relay store. This will ensure
Expand All @@ -313,7 +315,7 @@ function App(props: Props) {
fetchKey: (prev?.options.fetchKey ?? 0) + 1,
fetchPolicy: 'store-only',
},
variables: {id: 'different-id'}
variables,
}));
},
error: () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ function App(props: Props) {
const refetch = useCallback(() => {
if (isRefetching) { return; }
setIsRefetching(true);
const variables = { id: 'different-id' };

// fetchQuery will fetch the query and write
// the data to the Relay store. This will ensure
Expand All @@ -146,7 +147,7 @@ function App(props: Props) {
// At this point the data for the query should
// be cached, so we use the 'store-only'
// fetchPolicy to avoid suspending.
loadQuery({id: 'different-id'}, {fetchPolicy: 'store-only'});
loadQuery(variables, {fetchPolicy: 'store-only'});
},
error: () => {
setIsRefetching(false);
Expand Down Expand Up @@ -292,6 +293,7 @@ function App(props: Props) {
const refetch = useCallback(() => {
if (isRefreshing) { return; }
setIsRefreshing(true);
const variables = { id: 'different-id' };

// fetchQuery will fetch the query and write
// the data to the Relay store. This will ensure
Expand All @@ -313,7 +315,7 @@ function App(props: Props) {
fetchKey: (prev?.options.fetchKey ?? 0) + 1,
fetchPolicy: 'store-only',
},
variables: {id: 'different-id'}
variables,
}));
},
error: () => {
Expand Down

0 comments on commit 61c7de9

Please sign in to comment.