Skip to content

Commit

Permalink
fix reference comparison
Browse files Browse the repository at this point in the history
  • Loading branch information
shuding committed Dec 26, 2019
1 parent fafd22a commit 5795f33
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/use-swr-pages.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,12 @@ export function useSWRPages<OffsetType = any, Data = any, Error = any>(
) {
setPageSWRs(swrs => {
const _swrs = [...swrs]
_swrs[id] = swr
_swrs[id] = {
data: swr.data,
error: swr.error,
revalidate: swr.revalidate,
isValidating: swr.isValidating
}
return _swrs
})
if (typeof swr.data !== 'undefined') {
Expand Down

1 comment on commit 5795f33

@shuding
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because now all the substates (data, error, isValidating) are returned from getters which return refs (https://github.com/zeit/swr/pull/186/files#diff-ab20307c185620c9b54994fa4dcee1b7R608), the comparison result here (5795f33#diff-c9d2eb3ea821da85bd697b22fe31edf4R147) will always be true (both return the same ref).

This commit breaks the state object into a new one (which doesn't have the getters).

Please sign in to comment.