@ApplePieGiraffe
Posted
Hello, tediko! ๐
Amazing job on this challenge! ๐ And kudos for trying out React! ๐
Like Anna said, your design comparison is pixel-perfect! And I love the transitions you added to the various interactive elements of the site (especially the "Features" section). ๐คฉ
Here are a few tiny things I'd like to suggest,
- I don't think you need to wrap
<App />
in<React.Fragment>
inindex.js
because that is just a single component being rendered to the DOM.React.Fragment
is often useful when you have to render or return multiple elements and you don't want to wrap them in an unnecessary element such as<div>
. Also, if you ever do want to use fragments, you can use the empty tag syntax (like<>
) instead ofReact.Fragment
(it's like the same thing but just shorter and nicer to read)โexcept if you want to pass thekey
prop to the fragment (in which case you have to useReact.Fragment
instead). - In components like
Button.js
, you can use thechildren
prop to access whatever is put between the component's opening and closing tags, meaning instead of having atext
prop, you can simply includechildren
in the list of props to be destructured and then use{children}
instead of{text}
in your JSX. This will look nice when you are usingButton.js
and becomes especially helpful when you want to include components as the children of an element. - The information for the extension cards isn't something that you need to keep in state, because nothing about that information actually changes from render to render. You can simply include the data for the extension cards as an array outside the main function in
Extensions.js
. (The same can be done for the data for the FAQs.) - Also, this is just a tip, but if you have a component like
ExtensionsCard.js
within a folder namedExtensions
, I like to dropExtensions
in the name of the component (and name it something likeCard
), since it is already categorized by the name of its folder. It helps to keep names of things a little bit shorter and cleaner (but maybe that's just me). - You might already know this and just wanted to make the FAQs section with React, but you can use the native HTML
<details>
and<summary>
elements to easily create a fairly accessible accordion without having to use any JS (in fact, that's what we switched to for FAQs on Frontend Mentor). The only downside is that animating the height of the expanded state of the element is a slightly tricky. - If you ever use
useEffect
, remember to include a dependency array to make sure that that hook is only called when necessary (otherwise, it will be called on every render, I think). TheuseEffect
inuseFeaturesToggle.js
could probably take an empty array as its second argument so that it only adds an event listener once (when the component is mounted). TheuseEffect
inHeader.js
could maybe havewindowWidth
in its dependency array so that it re-runs only when that variable changes. (LOL, I used to forget to do this, too.) - I think what you have for the file structure of your project is good (especially for the size of this project). If you'd like to read more about how to structure React apps, Matt pointed me to this nice article in his feedback to one of my React solutions.
WowโI just realized how long this is! These are just of my thoughts, though, and I hope you'll find them helpful. ๐
Overall, you've done really well (especially for you first React projectโbetter than me, haha)! ๐
Of course, keep coding (and happy coding, too)! ๐
Marked as helpful
@ApplePieGiraffe
Posted
Oh, yes, and congratulations on submitting your 30th solution on Frontend Mentor! ๐
Also, thanks for the shoutout! ๐
@ApplePieGiraffe Hello, APG! Thank you for your comprehesive feedback! I will go over everything and learn a valuable lesson from it.
- Indeed, I don't need
<React.Fragment>
inindex.js
. I can keep it simple in one line. - Wow, children prop is really more cleaner and also have own adventages that you point. I changed it already!
- Right! Regarding this, when I was doing the feature section tabs (I left it for the end), I already made a separate file for the data because I noticed my mistake but it flew out of my head to change rest.
- Yeah, you're absolutely right. These names are due to the fact that in the beginning I had no division into folders, just kept everything in the Components folder. When my code grow I realized that I have to separate them and I didn't change names of files. I'll definitely use shorter names in future projects.
- It's funny because eight months ago you were first person to advised me to use
<details>
and<summary>
(it was for faq accordion card challenge). I had it in mind and I remembered it but for animation reason I decided to use buttons with aria-controls. Additionally, I wanted to do some logic work in React. - Good catch! I guess my thinking was (wrong ๐) that since I'm removing eventListener, I don't need to pass that empty array since it will remove on render anyway - but you've right.
Again, thank you for linking me an article and for valuable time consuming feedback. Have a great day!
@ApplePieGiraffe
Posted
@tediko
Awesome! ๐ I'm really glad to hear that it was helpful! ๐
Have a great day, as well! โ๏ธ