Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: fix all react-hooks/exhaustive-deps warnings in tests #902

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions test/use-swr-infinite.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ describe('useSWRInfinite', () => {
useEffect(() => {
// load next page if the current one is ready
if (size <= 2) setSize(size + 1)
// The setSize function is guaranteed to be referential equal
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [size])

return <div>{data}</div>
Expand Down
2 changes: 2 additions & 0 deletions test/use-swr-int.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,8 @@ describe('useSWR', () => {
revalidate()
}, 200)
return () => clearTimeout(timeout)
// the revalidate function is always the same reference because the key of the useSWR is static (broadcast-3)
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [])
return <>{isValidating ? 'true' : 'false'}</>
}
Expand Down
2 changes: 2 additions & 0 deletions test/use-swr-local-mutation.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -520,6 +520,8 @@ describe('useSWR - local mutation', () => {
return 2
}, false)
}, 1)
// the mutate function is guaranteed to be the same reference
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [])

renderRecivedValues.push(data) // should be 0 -> 2, never render 1 in between
Expand Down
4 changes: 4 additions & 0 deletions test/use-swr.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,8 @@ describe('useSWR', () => {
revalidate()
}, 200)
return () => clearTimeout(timeout)
// the revalidate function is always the same reference because the key of the useSWR is static (broadcast-3)
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [])
return <>{isValidating ? 'true' : 'false'}</>
}
Expand Down Expand Up @@ -1888,6 +1890,8 @@ describe('useSWR - local mutation', () => {
return 2
}, false)
}, 1)
// the mutate function is guaranteed to be the same reference
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [])

renderRecivedValues.push(data) // should be 0 -> 2, never render 1 in between
Expand Down