pinterest-for-woocommerce icon indicating copy to clipboard operation
pinterest-for-woocommerce copied to clipboard

Refactor common custom hooks so there is a single implementation of each

Open haszari opened this issue 3 years ago • 0 comments

For example, there are two implementations of useCreateNotice:

Screen Shot 2021-06-25 at 8 39 13 AM

Custom hooks like this should be decoupled from the components that use them, and should have a clearly defined interface. In general it's a good idea to implement custom hooks in a single lib folder, e.g. at top of assets/source/custom-hooks.

If different client components need different behaviour from the hooks, this should be implemented via arguments or separate hooks. Having multiple copies of similar custom hooks could easily lead to bugs in future and will be more complex to maintain.

haszari avatar Jun 24 '21 20:06 haszari