React
Introduction to React Hooks - Custom Hooks

Fixing a Broken Hook Exercise

PRO
Outline

Let's do an exercise to practice the syntax of a custom hook. To do this, you will fix the broken code in my custom hook.

1️⃣ Part 1 of this challenge will be to return the results, loading, and getResults variables from the hook so that they can be accessed in the UI.

2️⃣ Part 2 will be to add functionality to the useQuery hook inside the hooks folder. You will need to modify the effect to change the loading state to true or false, depending on if its the user's initial query and if there are results. If it is not the initial query and if there are no results, loading should be true so that the loading UI is displayed to the user.

You will also need to declare the necessary dependencies.

When you've finished, you'll have created some useful functionality for this custom React hook and the user will see a seamless UI.

Access the challenge on Stackblitz here.

 

I finished! On to the next chapter