mirror of
https://github.com/gosticks/react-table.git
synced 2025-10-16 11:55:36 +00:00
Fix hook defaults
This commit is contained in:
parent
1caad4cd8c
commit
9b262676be
@ -1,6 +1,12 @@
|
||||
module.exports = {
|
||||
trailingComma: 'es5',
|
||||
printWidth: 80,
|
||||
tabWidth: 2,
|
||||
useTabs: false,
|
||||
semi: false,
|
||||
singleQuote: true,
|
||||
trailingComma: 'es5',
|
||||
bracketSpacing: true,
|
||||
jsxBracketSameLine: false,
|
||||
arrowParens: 'avoid',
|
||||
endOfLine: 'auto',
|
||||
}
|
||||
|
||||
@ -12,7 +12,6 @@ import {
|
||||
} from '../utils'
|
||||
|
||||
import { useTableState } from './useTableState'
|
||||
import { useRows } from './useRows'
|
||||
|
||||
const propTypes = {
|
||||
// General
|
||||
@ -39,7 +38,6 @@ export const useTable = (props, ...plugins) => {
|
||||
let {
|
||||
data,
|
||||
state: userState,
|
||||
useRows: userUseRows = useRows,
|
||||
columns: userColumns,
|
||||
defaultColumn = {},
|
||||
subRowsKey = 'subRows',
|
||||
@ -80,9 +78,7 @@ export const useTable = (props, ...plugins) => {
|
||||
|
||||
if (debug) console.time('hooks')
|
||||
// Loop through plugins to build the api out
|
||||
api = [userUseRows, ...plugins]
|
||||
.filter(Boolean)
|
||||
.reduce((prev, next) => next(prev), api)
|
||||
api = plugins.filter(Boolean).reduce((prev, next) => next(prev), api)
|
||||
if (debug) console.timeEnd('hooks')
|
||||
|
||||
// Compute columns, headerGroups and headers
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
import React from 'react'
|
||||
import { useMemo } from 'react'
|
||||
import PropTypes from 'prop-types'
|
||||
|
||||
@ -48,10 +49,14 @@ export const useGroupBy = props => {
|
||||
// Sort grouped columns to the start of the column list
|
||||
// before the headers are built
|
||||
hooks.columnsBeforeHeaderGroups.push(columns => {
|
||||
return [
|
||||
...groupBy.map(g => columns.find(col => col.id === g)),
|
||||
...columns.filter(col => !groupBy.includes(col.id)),
|
||||
]
|
||||
// eslint-disable-next-line react-hooks/rules-of-hooks
|
||||
return React.useMemo(
|
||||
() => [
|
||||
...groupBy.map(g => columns.find(col => col.id === g)),
|
||||
...columns.filter(col => !groupBy.includes(col.id)),
|
||||
],
|
||||
[columns]
|
||||
)
|
||||
})
|
||||
|
||||
columns.forEach(column => {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user