API tip generator using React Vite w/TypeScript and Tailwind CSS

Solution retrospective
I'm proud of the structure of the site.
What challenges did you encounter, and how did you overcome them?Understanding API, Gemini Helped me out.
What specific areas of your project would you like help with?Learning how to use API faster.
Please log in to post a comment
Log in with GitHubCommunity feedback
- P@ttsoares
A precise solution!
Some comments:
-
It is odd the use of useless classes like: Box-container and Main-content. If you like to use references, it would better comments.
-
As your index.css has several definitions, it is not clear if you really want to use Tailwind or not...
-
About performance: Debounce the button and cache the results in localStorage:
const fetchAdvice = useCallback(async () => { if (loading) return; // Prevent concurrent fetches setLoading(true); try { const cachedAdvice = localStorage.getItem("cachedAdvice"); if (cachedAdvice) { const { slip } = JSON.parse(cachedAdvice); setAdvice(slip.advice); setAdviceId(slip.id); } const response = await fetch(API_URL, { cache: "no-store" }); const data = await response.json(); localStorage.setItem("cachedAdvice", JSON.stringify(data)); // ... rest of the logic } catch (err) { ... } }, [loading]);
-
Join our Discord community
Join thousands of Frontend Mentor community members taking the challenges, sharing resources, helping each other, and chatting about all things front-end!
Join our Discord