-
I'm having difficulties resetting my material-ui components. With a vanilla HTML form element, its simple. But with my custom material-ui component, it seems nearly impossible. export const ValidatedSelect: React.FC<ValidatedSelectProps> = ({
name,
children,
...selectProps
}) => {
const { error, getInputProps, validate, defaultValue } = useField(name);
const [value, setValue] = useState<any>();
useEffect(() => {
validate();
}, [value]);
const inputProps = getInputProps(selectProps);
return (
<Select
{...inputProps}
onChange={(e) => {
setValue(e.target.value);
inputProps?.onChange?.(e);
}}
error={!!error}
helperText={error}
autoComplete={name}
>
{children}
</Select>
);
}; Calling Any ideas how I can hack around this, I definetly won't be using Material on my next project after this issue. |
Beta Was this translation helpful? Give feedback.
Answered by
airjp73
Jul 20, 2022
Replies: 1 comment 1 reply
-
You'll want to use |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
dan-cooke
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You'll want to use
useControlField
for that.