Design comparison
Community feedback
- @mseidel819Posted over 2 years ago
looks good! I have a list of tiny things that I'll share:
-
Instead of 2 short circuit statements in App.js, you can also write 1 ternary operator:
{submitted ?<ThankYouModal rating={rating} /> : <RatingModal onHandleRating={handleRating} onHandleSubmit={handleSubmit} rating={rating} />}
-
when you pass props to a component, something you can do (especially if you end up using props a LOT in a component) is to destructure the props at the beginning: `const RatingButton = ({onHandleRating, num}) => {
const handleClick = () => { onHandleRating(num); } }
in this example,
propsgot destructured to
{onHandleRating, num}. Now, you don't have to include
props.` in front of them each time you use them. -
continuing in Rating.js, another way to handle the click event (i think) is to put
onClick={()=>onHandleRating(num)}
. Theconst handleClick
is good practice though for when you have a large function that you need to use. This function is so small that you could do either.
Marked as helpful0 -
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