suspend-react
suspend-react copied to clipboard
shallowEqualArrays falling short when using empty array as key
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.