ui
ui copied to clipboard
Thoughts on the Form component
Hi @shadcn,
This is the best project I have come across really appreciate the work, I would like to highlight performance-related stuff on the form component, which works perfectly but due to React Context on top of the Input component renders the Input again and again on every change in the HTML input which defies the react-hook-form working which works on ref
Solution and Changes:
- Refactor FormField to use the
useControllerhook - Remove the React Context which rerenders child components
Edit: Implementation - https://codesandbox.io/p/sandbox/ecstatic-ramanujan-krxy5t
@tushar1998 can you provide an example?
Yep here in code sandbox
https://codesandbox.io/s/goofy-cori-l9pxzh
Yep here in code sandbox
https://codesandbox.io/s/goofy-cori-l9pxzh
This example is still rerendering on every keystroke to me.
@mnpqraven I have added a render count on the top right corner in codesandbox example
@tushar1998 Totally agree with you. I want to read your solution, but it did not proceed from loading page. Did you remove the codesnadbox?
Since this discussing is getting attention I will make a repository for this and attach it in the issue itself cc: @isac322
Found it: https://codesandbox.io/p/sandbox/ecstatic-ramanujan-krxy5t
This issue has been automatically closed because it received no activity for a while. If you think it was closed by accident, please leave a comment. Thank you.
Can this be reopened?