Fixes for useExtended in useTable plus small bug (#1279)

* undefined error in GroupBy
row specific hooks and correct pathing for nested rows

* Ensuring correct git user
This commit is contained in:
Gary Menzel
2019-02-28 03:06:47 +11:00
committed by Tanner Linsley
parent 33f30c7b7f
commit a9971e66af
4 changed files with 10 additions and 6 deletions

2
dist/index.js vendored

File diff suppressed because one or more lines are too long

2
dist/index.js.map vendored

File diff suppressed because one or more lines are too long

View File

@@ -64,7 +64,7 @@ export const useGroupBy = props => {
const toggleGroupBy = (id, toggle) => {
return setState(old => {
const resolvedToggle =
typeof set !== 'undefined' ? toggle : !groupBy.includes(id)
typeof toggle !== 'undefined' ? toggle : !groupBy.includes(id)
if (resolvedToggle) {
return {
...old,

View File

@@ -139,14 +139,17 @@ export const useTable = (props, ...plugins) => {
// This function is absolutely necessary and MUST be called on
// any rows the user wishes to be displayed.
api.prepareRow = row => {
const { index } = row
const { path } = row
row.getRowProps = props =>
mergeProps(
{ key: ['row', index].join('_') },
{ key: ['row', path].join('_') },
applyHooks(api.hooks.getRowProps, row, api),
props
)
// need to apply any row specific hooks (useExpanded requires this)
applyHooks(api.hooks.row, row, api)
row.cells = row.cells.filter(cell => cell.column.visible)
row.cells.forEach(cell => {
@@ -157,7 +160,7 @@ export const useTable = (props, ...plugins) => {
const { column } = cell
cell.getCellProps = props => {
const columnPathStr = [index, column.id].join('_')
const columnPathStr = [path, column.id].join('_')
return mergeProps(
{
key: ['cell', columnPathStr].join('_')
@@ -167,6 +170,7 @@ export const useTable = (props, ...plugins) => {
)
}
cell.render = (type, userProps = {}) => {
if (!type) {
throw new Error(