Summary

Read the final remarks on the benefits of using the “useDependency” pattern.

This lesson taught you how to use React Hooks to manage dependencies for React components. By doing so, you can:

  • Share common logic
  • Reduce code repetition
  • Have better code composition
  • Make unit testing easier

It is suggested to explore this idea further by adding more options to the configuration. You can use this pattern with Redux or any other state management solution that you may be using.

Once you use this pattern in multiple features, you should see a noticeable reduction in the boilerplate or repetitive code.

You may also explore the managing transition states with this pattern. For example, a common fetch request results in the following three states:

  • Setting isLoading to true
  • Dispatch response and setting isLoading to false
  • Or dispatch error and setting isLoading to false

Get hands-on with 1400+ tech skills courses.