{ const f: FileList | null = e.currentTarget.files; if (!f || f.length != 1) { return; } if (f[0].size > MAX_IMAGE_UPLOAD_SIZE) { setSizeError(true); return; } setSizeError(false); return f[0].arrayBuffer().then((b) => { const b64 = btoa( new Uint8Array(b).reduce( (data, byte) => data + String.fromCharCode(byte), "", ), ); return onChange(`data:${f[0].type};base64,${b64}` as any); }); }} />
{sizeError &&Image should be smaller than 1 MB
}