Skip to content
This repository has been archived by the owner on Feb 23, 2024. It is now read-only.

Create stable action references in useForcedLayout to fix wp.com bug #7967

Conversation

alexflorisca
Copy link
Member

There is an issue on wp.com, where data store actions are patched by a tracking code. If any action on a data store is used inside a dependency array for a react hook, it will throw the code into an infinite loop. To prevent this, @senadir fix it by removing the dependencies from the array in #7367. This P2 (pca54o-4GY-p2) sums up the the problem and generated a discussion around it. Jarda proposed re-writing the code (pca54o-4GY-p2#comment-4658) using the wp/data registry rather than distructing the actions from useDispatch. This PR does exactly that.

Fixes #7637

Testing

User Facing Testing

I can't think of a robust way to test this, maybe @senadir knows a better way, but this is a smoke test:

  1. Create a new file assets/js/tracking.js and copy and paste the contents of this file
  2. Open up the Cart and Checkout blocks in the editor, and check that there are no console errors. Reload each of them a few times.
  • Do not include in the Testing Notes

WooCommerce Visibility

  • WooCommerce Core
  • Feature plugin
  • Experimental

Performance Impact

Changelog

Fix an issue with the Cart & Checkout blocks not loading correctly in the editor on wordpress.com

@alexflorisca alexflorisca requested a review from senadir December 16, 2022 11:10
@alexflorisca
Copy link
Member Author

alexflorisca commented Dec 16, 2022

Closing this issue because @opr already did it in https://github.com/woocommerce/woocommerce-blocks/pull/7879😞 . Should have pulled trunk earlier, my bad.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Experiment with proposed fix to useForcedLayout
1 participant