react-hook-form-mui icon indicating copy to clipboard operation
react-hook-form-mui copied to clipboard

onChange doesn't fire for TextFieldElement

Open sonusindhu opened this issue 3 years ago • 1 comments
trafficstars

Hi,

I am not able to figure it out how to fire the onChange event for TextFieldElement component.

Here is the Example I have tried.

Could you please let me know if anything special required.

Thanks for the plugin.

sonusindhu avatar Jun 15 '22 16:06 sonusindhu

The TextFieldElement is using onChange for the internal react-hook-form as you can see here: https://github.com/dohomi/react-hook-form-mui/blob/master/src/TextFieldElement.tsx#L41

If you want to watch changes on the TextFieldElement then just use react-hook-form for this:

const value = useWatch('nameOfTextfield');

dohomi avatar Jun 16 '22 01:06 dohomi