Design comparison
Solution retrospective
Hey everyone!
I just completed another challenge. 🤘🏽
This is my first time trying dynamic changes using React, the validator
library was very useful in the email validation part but I just have a couple of questions:
-
I want to display the error message based on
formData.isValid
state from CTA component on submit and not by explicitly checking ifvalidator.isEmail(formData.email)
is true (which also runs all the time when the value is changed as the form input's state is managed by React) -
How do you conditionally render the error message by only showing it based on the
formData.isValid
state, at the moment it shows directly on load; I tried changing theformData.isValid`` value by checking if
validator.isEmail(formData.email)is true on the
handleSubmit``` function but it only run once when the said state is changed by submitting a valid email and doesn't run again after when I tried testing with an invalid email.
Would really appreciate if you can help me with the queries above 🙏🏽
Feedback is always welcome. Please let me know of any issues you may find and/or how I can improve my code :)
Happy coding!
UPDATE:
I have solved the questions above, I just set up an error state and made it work!
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