Design comparison
Solution retrospective
It was my first project using React and it was very difficult but it was very useful and I learned a lot. Please feel free to let me a feedback !
Community feedback
- @Mod8124Posted over 2 years ago
Hi Good Job!
If you use react you don't have to use querySelector it's bad practice, react has its own hooks for that is called
useRef
, for exampleconst header = useRef(null); const changeColor = () => header.current.style.color = 'red' <h1 ref={header}><h1>
If you used useEffect always you need to put watch a keyword if you don't useEffect is going to render the component every time without limit
useEffect(()=>{ console.log('hola') }); //bad useEffect(()=>{ console.log('hola') },[ ]); //good, usually you put a variable if the variable change is going to console.log again
Finally, you use too many time the word props, so an easy way to use props and don't repeat that word is just to use Destructuring assignment it isn't bad but if you use too many times that word it's bad xD
const Header = (props) => { return ( <> <h1>{props.theme}</h1>) }; //bad const Header = ( { theme, color } ) => { return ( <> <h1>{theme}</h1>) }; //good
Marked as helpful2@Alain-sysPosted over 2 years ago@Mod8124 Hi, thank you for your response 🙂 I rewired my code with the destructive method. I already used this method in my todo-app project but forgot to update it.
About useRef I don’t really understand how it works. I tried on my project but it doesn’t work. I’ll continue my research and get back to you when it’s done.
For useEffect it’s not good what I did? My useEffect is like this: useEffect()=>{ console.log('hola') ................ },[matches, query ]);
How do you put your comment in code format ?
0@Mod8124Posted over 2 years ago👍 That's good
How do I write code format? well, there's an icon on your right when you write looks like this ⌨️, you can click it and see the options, it's called markdown if you want to see more about it :)
2@Alain-sysPosted about 2 years ago@Mod8124 Thanks for the resource ! I've finally change my querySelector in useRef 😊
1
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