React-Vite-Typescript Scss flexbox grid framer-motion redux-toolkit
Design comparison
Solution retrospective
first time trying with typescript any suggestions ?
Community feedback
- @antaryaPosted about 2 years ago
Hi 👋,
Nice job 🚀. I noticed a couple of things that can be improved.
HTML
[1. Use button tag instead of div tag for icon buttons, and do not forget to add
aria-label
for buttons with no text.[2. Usually, the logo is a link to the home page with an alt property set to the app name.
[3. Check responsiveness on screen size e.g. 692px.
JS/React/Typescript
[4. Typescript looks good; when possible, create reusable types, e.g.:
interface Image { poster: string; thumbnail: string; }
And use it whenever this type is used.
[5. If you use hard-coded data, move it out of the component, nothing is happening with it while rendering. A better approach would be to imitate fetch using a slight delay with a loading indicator to mimic the real application.
[6. The first parameter of the array splice method is the index at which to start changing the array. Using id to remove the item from the cart as the first parameter of splice will not work correctly.
[7. You can skip
<>...<>
as the root element when there is only one child element.[8. Use the
header
tag as a root element of theHeader
component instead of wrapping theHeader
component inApp
.[9. In
Cart
component you check if cart is empty several times, it is a good candidate to have it in a variable e.g.const isPresent = data?.length > 0
.[10.
useState<boolean>(false)
you can skip type here if you expect the value to be only boolean as typescript will know.[11. NavLinks will probably be reused in other places .e.g in the footer, so keep it outside the component and/or move it to its file.
General
[12. Use reset to have a good starting point, e.g. https://piccalil.li/blog/a-modern-css-reset/.
[13. For commit messages, it will help others if you add a descriptive message and follow a specific format, so all is consistent https://www.conventionalcommits.org/en/v1.0.0/. You can even make a check before committing if you follow those rules by using a tool like commitlint - https://commitlint.js.org/#/
Let me know if you have questions. I hope this will be helpful.
Keep up the good work 🚀. Cheers!
Marked as helpful1
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