Design comparison
SolutionDesign
Solution retrospective
I built this project this way because I wanted to try out some of React's more complex hooks rather than just using state for everything. Please comment with any critiques you may see. I'm looking to learn and get better :)
Community feedback
- @RafaelSS427Posted about 1 year ago
Hi Andrew, you did a great job! I found points in your code that you can improve.
- I recommend using the useEffect hook instead of using a conditional operator in your FormInput component. For example instead of this:
if (clear) { inputRef.current.value = null; }
Use this:
useEffect(() => { if (clear) { inputRef.current.value = null; } }, [clear, inputRef])
- The date validations do not work as they should. I recommend performing the validations with the Date object.
- You can improve the readability of your code by creating a custom hook for each context of your application and then using it. For example:
import { useContext } from 'react' import { UserContext } from '../App' export const useUserContext = () => { const state = useContext(UserContext); return { ...state } }
Marked as helpful0@dangero1990Posted about 1 year ago@RafaelSS427 thank you for your feedback. The custom hook makes a whole lot of sense, and I'm going to play around with your suggestions when I have some free time.
0
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