Careeroza
Real World Example
Real World: Async form submit reading the event
In old React 16 projects, reading e.target.value inside a debounce or after await returned null because of pooling. Today pooling is gone, but e.currentTarget still becomes null after the handler returns, so read what you need before the first await.
async function handleSubmit(e) {
e.preventDefault();
const data = new FormData(e.currentTarget); // ✓ read before await
await checkCaptcha();
// new FormData(e.currentTarget) here would fail: currentTarget is null now
await fetch('/api/signup', { method: 'POST', body: data });
}
// React 16 code you may still find in old projects:
function handleChange(e) {
e.persist(); // needed for pooled events
debouncedSearch(e.target.value);
}