Challenge: Create a Data Fetching custom hook
Follow these instructions to complete your challenge:
- Create a custom hook called
useFetch.
- The hook should accept a URL as an argument and fetch data from that URL.
- It should return
loading state, error state, and data.
- Use this hook inside the App component to fetch data from https://jsonplaceholder.typicode.com/posts/1.
- Display "Loading..." while fetching and show the title of the fetched post once the request is complete.
- If an error occurs, display "An error occurred!".