Countries rest Api app with React, React Router, mobile first
Design comparison
Solution retrospective
Hi Guys. any advice on how can I improve my code will be much welcome .
Community feedback
- @SkidragonPosted over 3 years ago
Hi @tomsky90, nice job on the dark mode and filtering. I do recommend to setup prettier to format your code to make it look nicer and not worry about formatting code. Also the components need to be simplified more, for example:
const HomePage = ({ error, setError, darkMode, countriesListData, countriesDataForDisplay, setCountriesDataForDisplay, selectValue, setSelectValue, inputValue, setInputValue, }) => { return ( <div> <Form setError={setError} darkMode={darkMode} countriesListData={countriesListData} countriesDataForDisplay={countriesDataForDisplay} setCountriesDataForDisplay={setCountriesDataForDisplay} selectValue={selectValue} setSelectValue={setSelectValue} inputValue={inputValue} setInputValue={setInputValue} />
this is like saying in vanilla js land Form(setError, darkMode, countriesListData, countriesDataForDisplay, setCountriesDataForDisplay, selectValue, setSelectValue, inputValue, setInputValue), I as a developer of this re-usable component wouldn't want to deal with. It needs to be more generic of a form. For example:
<Form isDarkMode={true} //the "is" tells me it's a boolean data={[]} onSubmit={() => { // fetch, set your countries, set errors, and set load here }} onInputValueChange={() => {}} onSelectValueChange={() => {}}
This way you can re-use the component in more than one place.
0@tomsky90Posted over 3 years ago@Skidragon I thought it was getting a little bit out of control but didn't know how to sort it. Thank you for your advice, I will bare that in mind and try to implement it.
0 - @besopmacPosted over 3 years ago
This comment was deleted over 3 years ago
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