[FEATURE] Refactor Component Logic by Using Custom Hooks for Cleaner Code
Problem
I've noticed that in a lot of our components, especially in signup and signin, we’re combining all the logic and UI in one file. Over time, this is making things harder to maintain and more cluttered. As the project grows, it feels like we might run into problems with scalability and readability.
Solution
What I’m thinking is that we could create custom hooks for all the logic. That way, we keep the components focused on the UI and the hooks handle the logic. We can import these hooks wherever needed, keeping the components cleaner and the code more modular. This would help with organization and make everything easier to manage as we keep building out the project.
Alternative
We could create separate components for the logic, but I feel like hooks might be a simpler and cleaner approach. Keeping everything in one file feels like it could get messy, especially as we add more features.
Anything else?
I’m still getting my head around the project, so I’m not entirely sure if this is the best solution. I wanted to see if this approach sounds good to you, or if there’s something specific I should consider while trying to make this change.
agree with the current structure being messy, i don't see how an auth-form.tsx component wouldn't be clean though
keeping everything in one file feels like it could get messy, especially as we add more features.
i think this is fine for an auth component where it's rare new features are added if at all. these are scalability concerns that'll probably never happen
what do you think?
According to me, auth-form.tsx would make jsx structure more clean . like in future if you ever plan to add more variants (reset-password, change-email, SSO or 2 factor auth) etc then it would help to avoid duplication.
@mazeincoding, I get your point that for a simple auth component, scalability might not be an immediate concern. However, if we plan to add features like reset-password or SSO later, modularising now could save us from duplication and make things cleaner, as @DevloperAmanSingh mentioned.
In short, I think starting with a modular approach will help keep things organized and scalable in the long run.
Also, I think it’s important to apply this modular approach consistently across both small and large components. Having a uniform structure will help with scalability and maintainability in the long run.
@Harshitshukla0208 hey, can you verify what have u implemented? where did u create custom hooks?
@mazeincoding Could you assign this one to me? I would like to work on this. if it's needed.