Hey. Is this supposed to happen? When removingt form.getInputProps it works fine, but adding it stops the onChange even from emitting.
Basically, I have this function which runs whenever the input inside of a mantine <Textarea /> changes, and I need this to run. But it doesn't run when this component is attached to a Mantine useForm.
return (
<div className="textAreaContainer">
<Textarea
onChange={(event) => {
console.log(1);
handleChange(event);
}}
styles={(theme) => ({
input: {
backgroundColor: theme.colors.dark[9],
},
})}
placeholder={placeHolderText}
value={settings.newSettings[settingName]}
maxLength={maxLength}
autosize={true}
minRows={2}
maxRows={5}
required={required}
{...form.getInputProps(settingName)}
/>
)
To attempt to fix this problem I looked at the docs and found the form.isDirty method. However, the problem which this causes is an infinite loop due to the page re-rendering due to my handleChange function updating the state of charCount.
const handleChange = (value: string) => {
setCharCount(value.length);
};
// when the value for this form element changes
if (form.isDirty(settingName)) handleChange(form.values[settingName]);
return (
<Textarea
styles={(theme) => ({
input: {
backgroundColor: theme.colors.dark[9],
},
})}
placeholder={placeHolderText}
maxLength={maxLength}
required={required}
{...form.getInputProps(settingName)}
></Textarea>