Design comparison
Solution retrospective
I've re-used some of the components from the previous exercise.
To verify the fields, react-hook-form comes in clutch once again.
My question for this exercise: I'm repeating the same code in the <input ...../> part four times. They're quite similar, so would it make sense to create another component? Will it affect the overall performance of my app by doing so as I'll be calling the component to render it and also calling my <Errors ... /> component four times.
My </Errors /> component takes a prop like so:
-
if it's a non-email field:
<Errors word={"Last Name"} />
-
if there's an email field:
<Errors email={"true"}
and then render it conditionally in the component below:
{props.email ? ( <div>Looks like this is not an email</div> ) : ( <p>{props.word} cannot be empty</p> )}
Any improvement and feedback you could give me, please do so :)
Only 4 novice exercise left 🎉
Community feedback
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