useSelect() plus resolver result is serving cached data incorrectly

Thanks for MVE, @helgatheviking! It was beneficial.

When wp.data caches the resolvers, it also considers arguments. Here’s what happens when following the reproduction steps for the bug:

  1. Selecting the first product resolves data, creates a cache for getProduct(1), and sets a value for the product state.
  2. Selecting second does the same (cache: getProduct(2)) and sets a new value for the product state.
  3. When switching back to the first product, wp.data knows the resolution was successful, so it calls the selector. The selector returns the latest product state for Product #2 set in step 2.

Solution: Use product ID as key when storing them in state, so selectors return correct data. Here’s the updated fork – https://codesandbox.io/p/sandbox/mve-product-store-example-cached-resolve-value-forked-8lqv3r?file=%2Fsrc%2Fdata%2Findex.js.

P.S. You can check cached resolvers by running – select( storeName ).getCachedResolvers().

deneme bonusu veren sitelerbahis siteleripulibet girişdeneme bonusutürkçe altyazılı pornocanlı bahis casinocanlı bahis casino siteleriOnwin Güncel Girişholiganbetholiganbet girişholiganbet güncel girişnewsnewsnewsnewsnewsnewsnewsnewsnewsnewsnewsnewsnewsnewsnewsnewsnewsnewsnewsnewsnewsnews