Frontendx
Frontendx
README.md
SOLUTION.md
main.tsxentry
App.tsx
App.css
index.html
vite.config.ts
Plugins
Installed
react@^19.2.0
react-dom@^19.2.0
Editor
useFetch Hook
Description
Implement useFetch(fetcher) so it returns data, loading, and error. Build a demo around a local mock async fetcher that uses setTimeout and never calls the network.
Show loading, success data, and an error state with a Retry button. Include a control that triggers a failing request so the error path can be demonstrated.
Examples
Example 1
The demo starts loading, then displays "Mock data loaded". Selecting Fail request displays an error and Retry runs the request again.
Constraints
- The mock fetcher must work offline.
- Every request must expose an accurate loading state.
- Retry must attempt the request again and clear the previous error.
Store data, loading, and error separately so each request can reset them.
Preview
Terminal
Test Results
useFetch Hook
Implement a useFetch hook that returns data, loading, and error, with a demo using a mock fetcher.