Skip to content

Commit 9b26267

Browse files
committed
Fix hook defaults
1 parent 1caad4c commit 9b26267

File tree

3 files changed

+17
-10
lines changed

3 files changed

+17
-10
lines changed

prettier.config.js

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
module.exports = {
2-
trailingComma: 'es5',
2+
printWidth: 80,
33
tabWidth: 2,
4+
useTabs: false,
45
semi: false,
56
singleQuote: true,
7+
trailingComma: 'es5',
8+
bracketSpacing: true,
9+
jsxBracketSameLine: false,
10+
arrowParens: 'avoid',
11+
endOfLine: 'auto',
612
}

src/hooks/useTable.js

+1-5
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import {
1212
} from '../utils'
1313

1414
import { useTableState } from './useTableState'
15-
import { useRows } from './useRows'
1615

1716
const propTypes = {
1817
// General
@@ -39,7 +38,6 @@ export const useTable = (props, ...plugins) => {
3938
let {
4039
data,
4140
state: userState,
42-
useRows: userUseRows = useRows,
4341
columns: userColumns,
4442
defaultColumn = {},
4543
subRowsKey = 'subRows',
@@ -80,9 +78,7 @@ export const useTable = (props, ...plugins) => {
8078

8179
if (debug) console.time('hooks')
8280
// Loop through plugins to build the api out
83-
api = [userUseRows, ...plugins]
84-
.filter(Boolean)
85-
.reduce((prev, next) => next(prev), api)
81+
api = plugins.filter(Boolean).reduce((prev, next) => next(prev), api)
8682
if (debug) console.timeEnd('hooks')
8783

8884
// Compute columns, headerGroups and headers

src/plugin-hooks/useGroupBy.js

+9-4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import React from 'react'
12
import { useMemo } from 'react'
23
import PropTypes from 'prop-types'
34

@@ -48,10 +49,14 @@ export const useGroupBy = props => {
4849
// Sort grouped columns to the start of the column list
4950
// before the headers are built
5051
hooks.columnsBeforeHeaderGroups.push(columns => {
51-
return [
52-
...groupBy.map(g => columns.find(col => col.id === g)),
53-
...columns.filter(col => !groupBy.includes(col.id)),
54-
]
52+
// eslint-disable-next-line react-hooks/rules-of-hooks
53+
return React.useMemo(
54+
() => [
55+
...groupBy.map(g => columns.find(col => col.id === g)),
56+
...columns.filter(col => !groupBy.includes(col.id)),
57+
],
58+
[columns]
59+
)
5560
})
5661

5762
columns.forEach(column => {

0 commit comments

Comments
 (0)