
useRowStateuseRowState is a plugin hook that implements basic state management for prepared rows and their cells.
The following options are supported via the main options object passed to useTable(options)
initialState.rowState: Object<RowPathKey:Object<any, cellState: {columnId: Object}>>{}cellState key, which provides cell-level state based on column ID's to every
prepared cell in the table.initialRowStateAccessor: Function(row) => Object<any>row => ({})Row object, from which you can return a value to use as the initial state, eg. row => row.original.initialStateinitialCellStateAccessor: Function(cell) => Object<any>cell => ({})Cell object, from which you can return a value to use as the initial state, eg. cell => cell.row.original.initialCellState[cell.column.id]autoResetRowState: Booleantruetrue, the rowState state will automatically reset if any of the following conditions are met:data is changedfalseThe following values are provided to the table instance:
setRowState: Function(rowPath: Array<string>, updater: Function | Any) => voidupdater can be a function or value. If a function is passed, it will receive the current value and expect a new one to be returned.setCellState: Function(rowPath: Array<string>, columnId: String, updater: Function | Any) => voidupdater can be a function or value. If a function is passed, it will receive the current value and expect a new one to be returned.The following additional properties are available on every prepared row object returned by the table instance.
state: ObjectrowState object via rowState[row.id]cellState key/value pair, which is used to provide individual cell states to this row's cellssetState: Function(updater: Function | any)updater can be a function or value. If a function is passed, it will receive the current value and expect a new one to be returned.The following additional properties are available on every Cell object returned in an array of cells on every row object.
state: ObjectrowState object via rowState[row.id].cellState[columnId]setState: Function(updater: Function | any)updater can be a function or value. If a function is passed, it will receive the current value and expect a new one to be returned.The best JavaScript newsletter! Delivered every Monday to over 76,000 devs.