Replies: 2 comments
-
const { data: ndata = { data: { list: [], total: 0 } }, isFetching, refetch } = queryList; |
Beta Was this translation helpful? Give feedback.
0 replies
-
don't call |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
const [data, setData] = useData({
pageSize: 10,
pageNo: 1,
cn: "",
total: 0,
list: [],
version: 0,
visible: false,
formVersion: 0,
});
const queryList = useQuery(["lists", { pageNo, pageSize, cn }], () => { console.log(cn); getData(pageNo, pageSize, cn) }, {
// refetchOnWindowFocus: false,
// retry: true,
// keepPreviousData: true,
enabled: false
})
const handleSearch = (cns) => {
// clearTimeout(timer)
setData({ cn: cns, version: Date.now(), pageNo: 1 });
refetch()
// timer = setTimeout(() => refetch(), 40)
}
When "enabled" is false, the method refetch is called. The CN field always reads the last value. I guess it is caused by the react hook closure trap. How to solve it
Beta Was this translation helpful? Give feedback.
All reactions