This post provides tips and tricks on how to work effectively with the useSelect hook from the @wordpress/data library. It discusses the importance of declaring useSelect dependencies, calling selector functions inside the callback, and selecting precise data. It also covers the use of objects and value properties in the
•11m read time• From developer.wordpress.org
Table of contents
Always declare useSelect dependenciesCall selector functions inside the callback, not outsideBut call them outside when you’re in an event handlerInside the callback, select precisely the data you needBe careful about transforming data inside the callbackPrefer returning objects with value properties from the callbackDo all selections from the same store in one callbackIt’s more subtle when selecting from multiple storesSort: