bietkul / react-reactive-form

Angular like reactive forms in React.
MIT License
309 stars 32 forks source link

Is this working with React Functional component and hooks? #83

Closed ArchanaSharma95 closed 2 years ago

ArchanaSharma95 commented 2 years ago

I am facing an issue with React functional component. I have initialized the formgroup but after every renders it reinitializes the form variable. Is this support React functional components and hooks? If yes, please provide some example codes to work with React functional components and Hooks.

Thanks.

bietkul commented 2 years ago

You can not initialize form control in render method without using useRef because it would reset controls on every re-render. The solution is to use useRef or define controls outside functional component.