React + Spring Boot CRUD App (Frontend) - Interview Cheat Sheet
1. useState Hook
Manages local state in functional components.
Example: const [user, setUser] = useState({ name: '', email: '' })
2. Validation Logic
Uses regex and a separate 'errors' object to store validation messages per field.
3. Form Handling
handleChange updates the user state and runs field-level validation.
handleSubmit checks errors and submits via addUser().
4. Conditional Rendering
Toggles between <UserForm /> and <UserTable /> using a showUsers state.
5. Age Calculation
DOB is compared to today's date using Date objects to calculate age.
6. Refresh Logic
refreshUsers() toggles showUsers to force re-render and refetch updated data.
7. Inline Styling
CSS is applied using style={{ ... }} objects directly in JSX tags.
8. Axios Services
getUsers, addUser, updateUser, deleteUser make API calls to backend via axios.
9. Interview Tip
Always explain controlled components, validation, conditional rendering, and re-render logic.