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

fix: replaceDeepEqual special case for non-plain arrays #3669

Merged
merged 2 commits into from Jun 6, 2022

Conversation

jxom
Copy link
Contributor

@jxom jxom commented Jun 4, 2022

It turns out that the replaceDeepEqual function wasn't returning the intended value for objects that are non-plain arrays.

E.g.

const prev = Object.assign([1, 2], { a: { b: 'b' }, c: 'c' })
const next = Object.assign([1, 2], { a: { b: 'b' }, c: 'c' })

replaceDeepEqual(prev, next) // result: [1, 2]

This data structure is used in libraries such as ethers and their contract Result value.

I'm not sure if we should perform structural sharing on these values as they are not really "JSON-compatible" values as mentioned in the docs, so I added a change which just checks if the given array is a "plain array", and if it is not, it has changed.

@vercel
Copy link

vercel bot commented Jun 4, 2022

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated
react-query ✅ Ready (Inspect) Visit Preview Jun 5, 2022 at 10:09PM (UTC)

@codesandbox-ci
Copy link

codesandbox-ci bot commented Jun 4, 2022

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 1b4633a:

Sandbox Source
tannerlinsley/react-query: basic Configuration
tannerlinsley/react-query Configuration

src/core/utils.ts Outdated Show resolved Hide resolved
src/core/utils.ts Outdated Show resolved Hide resolved
@jxom
Copy link
Contributor Author

jxom commented Jun 5, 2022

@TkDodo your wishes have been granted

@jxom jxom requested a review from TkDodo June 5, 2022 22:17
@codecov
Copy link

codecov bot commented Jun 6, 2022

Codecov Report

Merging #3669 (1b4633a) into beta (f77f6f4) will increase coverage by 0.00%.
The diff coverage is 100.00%.

@@           Coverage Diff           @@
##             beta    #3669   +/-   ##
=======================================
  Coverage   97.11%   97.11%           
=======================================
  Files          50       50           
  Lines        2389     2391    +2     
  Branches      705      706    +1     
=======================================
+ Hits         2320     2322    +2     
  Misses         67       67           
  Partials        2        2           
Impacted Files Coverage Δ
src/core/utils.ts 100.00% <100.00%> (ø)
src/core/infiniteQueryObserver.ts 100.00% <0.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f77f6f4...1b4633a. Read the comment docs.

@TkDodo TkDodo merged commit a46ba65 into TanStack:beta Jun 6, 2022
@tannerlinsley
Copy link
Collaborator

🎉 This PR is included in version 4.0.0-beta.22 🎉

The release is available on:

Your semantic-release bot 📦🚀

GLabat pushed a commit to GLabat/react-query that referenced this pull request Jun 27, 2022
…k-beta

* 'beta' of https://github.com/TanStack/query: (140 commits)
  Fix Best of JS badge in README (TanStack#3695)
  Update config.json
  docs: adapter teasers
  docs: rewrite typescript docs
  tests: stabilize
  docs: Update graphql.md to fix link (TanStack#3683)
  docs: fix link typo in README.md (TanStack#3679)
  Update README.md
  update readme
  Update config.json
  Update index.js
  examples: vendor to platform directories
  docs: migrate to tanstack.com
  fix(persist): introduce in-house synchronous Storage interface (TanStack#3673)
  docs: restructure migration guide by importance of breaking changes
  fix: `replaceDeepEqual` special case for non-plain arrays (TanStack#3669)
  feat: make InfiniteQueryObserver's type more robust (TanStack#3571)
  fix(types): remove non-void constraint from queryFn result (TanStack#3666)
  fix(persist): remove environment check (TanStack#3658)
  fix(types): make sure queryClient.setQueriesData can return undefined from the updater (TanStack#3657)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants