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