Design comparison
SolutionDesign
Solution retrospective
It was easy, but a good challenge. It's the first time I've combined React with Tailwind and I'm happy with the result. I'm still not entirely sure how data fetch works, but I managed to get it done.
Community feedback
- @fazzaamiarsoPosted over 1 year ago
Hi @SoulRvr29! Great work on your project, the README is fantastic!
You can use 1 state for this project. Example
// `advice` become an object const [advice, setAdvice] = useState({}); // then you can get the advice data const adviceContent = advice.advice; const adviceId = advice.id useEffect(() => { clickHandler(); }, []); const clickHandler = () => { fetch("https://api.adviceslip.com/advice") .then((response) => { if (response.ok) { return response.json(); } else { console.log("no data"); } }) .then((data) => { setAdvice(data.slip) }) .catch((err) => { console.log("Something went wrong!", err); }); };
I hope it helps! Cheers!
Marked as helpful1@SoulRvr29Posted over 1 year ago@fazzaamiarso You're right, I changed the code. Thanks for the help.
0 - @KeoLamolaPosted over 1 year ago
Hi @SoulRvr29 great work I must say. I m really inspired by your work, honestly do. Keep up the good work, I m learning so much from your journey. #cheers
0
Please log in to post a comment
Log in with GitHubJoin 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