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

shallowEqualArrays falling short when using empty array as key #19

Open
tom2strobl opened this issue Mar 17, 2023 · 0 comments
Open

shallowEqualArrays falling short when using empty array as key #19

tom2strobl opened this issue Mar 17, 2023 · 0 comments

Comments

@tom2strobl
Copy link

If a key is an empty array, suspend is called in an infinite loop, due to [] !== [] in js

// lets say this returns "[]"
const invoices = someCallFromDb()
// this is never settled, infinite looped
const paymentMoraleValues = suspend(
  async () => paymentMoraleFromInvoices(invoices),
  ['paymentMoraleValues', invoices]
)

Here's a sandbox for reproduction: https://codesandbox.io/s/suspend-react-infinite-rerender-mq391t

I know one can provide custom equality functions, but should such a basic case not be covered straight out of the box?

Would be a simple as making shallowEqualArrays account for it.

@tom2strobl tom2strobl changed the title shallowEqualArrays falling short in a very basic way shallowEqualArrays falling short when using empty array as key Mar 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant