Skip to content

Commit 2323359

Browse files
author
Satish Yadav
committed
fetch on click of button
1 parent 020fe64 commit 2323359

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/components/RQSuperHeroes.page.jsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,18 @@ const fetchSuperHeroes = () =>
66
axios.get('http://localhost:4000/superheroes').then(res => res.data);
77

88
function RQSuperHeroesPage() {
9-
const { isLoading, data, isError, error, isFetching } = useQuery(
9+
const { isLoading, data, isError, error, isFetching, refetch } = useQuery(
1010
['super-heros'],
1111
fetchSuperHeroes,
1212
{
13-
refetchInterval: 2000,
14-
refetchIntervalInBackground: true
13+
enabled: false
1514
}
1615
);
1716

1817
return (
1918
<>
2019
<h2>Super Heroes Page</h2>
20+
<button onClick={refetch}>Fetch Heros data</button>
2121
{isFetching && (<h4>Updating...</h4>)}
2222
{isLoading ? (
2323
<h3>Heros data Loading...</h3>

0 commit comments

Comments
 (0)