Transform and validate data with Hooks
masterYou can use hooks to alter raw data or perform custom validations at different stages of the import flow:
Step-based Hooks (Run once per step)
uploadStepHook: Runs once after the file is uploaded.selectHeaderStepHook: Runs once after the header row is selected.matchColumnsStepHook: Runs once after column mapping. Best for expensive operations.
Validation Step Hooks
tableHook: Runs at the start and on any change. Runs on all rows. Use this for complex validations where rows depend on each other (expensive).rowHook: Runs at the start and on any row change. Runs only on changed rows. Best for most transformations and validations (fast).
<ReactSpreadsheetImport
rowHook={(data, addError) => {
// Validation
if (data.name === "John") {
addError("name", { message: "No Johns allowed", level: "info" })
}
// Transformation
return { ...data, name: "Not John" }
}}
/>