Skip to main content
React Code Reorder Medium +20 XP

Custom Hook

Arrange a custom hook that fetches data.

Click lines in the correct order

Available lines4 left

Your order

Click lines above to build your solution.

Show answer and explanation

Answer: function useFetch(url) { const [data, setData] = useState(null); const [loading, setLoading] = useState(true); return { data, loading }; }

Function declaration, then state setup, then return the values.

Hint: Declare the hook, then state, then return.

What this challenge tests

Code Reorder in React: custom-hooks, patterns.

Related challenges