T
TanStack3y ago
sensitive-blue

table get refreshed even when the underling data are unchanged (based on react query).

I am using react query to fetch the data every second, but usually the data are static, but even the data are not changed, the react table got refreshed every 1 second. Shouldn't we expect it to fresh only when data are change? the code snippet is as below ``` const { isLoading, isFetching, isError, data: jobs, error, isSuccess, } = useQuery({ queryKey: ["jobs"], queryFn: () => fetch(url).then((res) => res.json()), refetchInterval: 1000, staleTime: 20000, }); const [data, setData] = React.useState(() => [...defaultData]); useEffect(() => { if (isSuccess) { setData(jobs["Jobs"]); console.log(jobs); } }, [jobs]); const table = useReactTable({ data, columns, getCoreRowModel: getCoreRowModel(), });
0 Replies
No replies yetBe the first to reply to this messageJoin

Did you find this page helpful?