Design comparison
SolutionDesign
Community feedback
- @notapatchPosted about 3 years ago
I have a question. When you imported the data in you cached it in a useState hook. Is that standard practice?
#src/App.js
import data from './data.json'; function App() { const [details, setDetails] = useState(data); // <=== This bit ... }
0@annacsillaxsPosted about 3 years agoHi @notapatch,
I've learnt this pattern from John Smilga's React Tutorial and Projects Course on Udemy. I've really just started working with React, and I just followed what I'd seen before. I've found this site, he fetches data in a similar way so I think it's a common pattern. https://www.robinwieruch.de/react-hooks-fetch-data
1@notapatchPosted about 3 years ago@annacsillaxs Cheers, that all makes sense. Couldn't find the words to Google it.
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