( setData: React.Dispatch<React.SetStateAction<Person[]>>, skipAutoResetPageIndex: () => void, )
| 156 | ] |
| 157 | |
| 158 | export const getTableMeta = ( |
| 159 | setData: React.Dispatch<React.SetStateAction<Person[]>>, |
| 160 | skipAutoResetPageIndex: () => void, |
| 161 | ) => |
| 162 | ({ |
| 163 | updateData: (rowIndex, columnId, value) => { |
| 164 | // Skip age index reset until after next rerender |
| 165 | skipAutoResetPageIndex() |
| 166 | setData((old) => |
| 167 | old.map((row, index) => { |
| 168 | if (index !== rowIndex) return row |
| 169 | |
| 170 | return { |
| 171 | ...old[rowIndex]!, |
| 172 | [columnId]: value, |
| 173 | } |
| 174 | }), |
| 175 | ) |
| 176 | }, |
| 177 | }) as TableMeta |