fix(calendar): remove setState call from render in isFormValid

validateUrl() calls setUrlError() — calling it during render triggers
React error #301 (cannot update component while rendering). Remove it
from the isFormValid computation; onChange/onBlur already keep urlError
in sync so !urlError is sufficient.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-07-01 13:01:03 +02:00
parent f6173bbe35
commit 2e0e7290ba
@@ -94,13 +94,14 @@ export function CalendarSourceForm({
} }
}, [t]); }, [t]);
// Form is valid when name, type, and url are filled and url is https // Form is valid when name, type, and url are filled and url passed validation.
// Do NOT call validateUrl here — it calls setUrlError which is a state update
// during render (React error #301). onChange/onBlur already set urlError.
const isFormValid = const isFormValid =
name.trim() !== '' && name.trim() !== '' &&
type !== '' && type !== '' &&
url.trim() !== '' && url.trim() !== '' &&
!urlError && !urlError;
validateUrl(url);
const handleSubmit = useCallback( const handleSubmit = useCallback(
async (e: React.FormEvent) => { async (e: React.FormEvent) => {