ui icon indicating copy to clipboard operation
ui copied to clipboard

Thoughts on the Form component

Open tushar1998 opened this issue 2 years ago • 6 comments
trafficstars

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 useController hook
  • Remove the React Context which rerenders child components

Edit: Implementation - https://codesandbox.io/p/sandbox/ecstatic-ramanujan-krxy5t

tushar1998 avatar Aug 13 '23 19:08 tushar1998

@tushar1998 can you provide an example?

nuno avatar Sep 08 '23 07:09 nuno

Yep here in code sandbox

https://codesandbox.io/s/goofy-cori-l9pxzh

tushar1998 avatar Sep 08 '23 20:09 tushar1998

Yep here in code sandbox

https://codesandbox.io/s/goofy-cori-l9pxzh

This example is still rerendering on every keystroke to me.

mnpqraven avatar Oct 04 '23 02:10 mnpqraven

@mnpqraven I have added a render count on the top right corner in codesandbox example

tushar1998 avatar Oct 04 '23 05:10 tushar1998

@tushar1998 Totally agree with you. I want to read your solution, but it did not proceed from loading page. Did you remove the codesnadbox?

isac322 avatar May 19 '24 23:05 isac322

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

tushar1998 avatar May 21 '24 12:05 tushar1998

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.

shadcn avatar Jul 05 '24 23:07 shadcn

Can this be reopened?

BrendanC23 avatar Jul 06 '24 00:07 BrendanC23