with useEffect (#609)

This commit is contained in:
Thibaut Sardan
2021-01-04 15:31:03 +01:00
committed by GitHub
parent cb8f873729
commit 261e357bd5
3 changed files with 25 additions and 6 deletions
@@ -26,6 +26,12 @@ function ValidatedInput<T extends Record<string, unknown>> ({ className, compone
const [validationResult, setValidationResult] = useState<Result<string>>(Result.ok(''));
const isMounted = useIsMounted();
useEffect(() => {
if (defaultValue) {
setValue(defaultValue);
}
}, [defaultValue]);
useEffect(() => {
// Do not show any error on first mount
if (!isMounted) {