mirror of
https://github.com/gosticks/react-table.git
synced 2026-02-25 18:12:50 +00:00
Fix renderer functions for blank headers
This commit is contained in:
parent
b2ed18696f
commit
ea79cd8388
@ -1,4 +1,4 @@
|
||||
import { useMemo } from 'react'
|
||||
import React from 'react'
|
||||
import PropTypes from 'prop-types'
|
||||
|
||||
const propTypes = {
|
||||
@ -10,7 +10,7 @@ export const useRows = props => {
|
||||
|
||||
const { debug, columns, subRowsKey = 'subRows', data } = props
|
||||
|
||||
const accessedRows = useMemo(() => {
|
||||
const accessedRows = React.useMemo(() => {
|
||||
if (debug) console.info('getAccessedRows')
|
||||
|
||||
// Access the row's data
|
||||
|
||||
@ -21,7 +21,7 @@ export const useTable = (props, ...plugins) => {
|
||||
|
||||
// Destructure props
|
||||
let {
|
||||
data = [],
|
||||
data,
|
||||
state: userState,
|
||||
useColumns: userUseColumns = useColumns,
|
||||
useRows: userUseRows = useRows,
|
||||
@ -44,10 +44,9 @@ export const useTable = (props, ...plugins) => {
|
||||
headerGroups: [],
|
||||
rows: [],
|
||||
row: [],
|
||||
renderableRows: [],
|
||||
getTableProps: [],
|
||||
getRowProps: [],
|
||||
getHeaderRowProps: [],
|
||||
getHeaderGroupProps: [],
|
||||
getHeaderProps: [],
|
||||
getCellProps: [],
|
||||
}
|
||||
@ -87,7 +86,7 @@ export const useTable = (props, ...plugins) => {
|
||||
column.render = (type, userProps = {}) => {
|
||||
const Comp = typeof type === 'string' ? column[type] : type
|
||||
|
||||
if (!Comp) {
|
||||
if (typeof Comp === 'undefined') {
|
||||
throw new Error(renderErr)
|
||||
}
|
||||
|
||||
@ -134,12 +133,12 @@ export const useTable = (props, ...plugins) => {
|
||||
|
||||
// Give headerGroups getRowProps
|
||||
if (headerGroup.headers.length) {
|
||||
headerGroup.getRowProps = (props = {}) =>
|
||||
headerGroup.getHeaderGroupProps = (props = {}) =>
|
||||
mergeProps(
|
||||
{
|
||||
key: [`header${i}`].join('_'),
|
||||
},
|
||||
applyPropHooks(api.hooks.getHeaderRowProps, headerGroup, api),
|
||||
applyPropHooks(api.hooks.getHeaderGroupProps, headerGroup, api),
|
||||
props
|
||||
)
|
||||
return true
|
||||
@ -195,7 +194,7 @@ export const useTable = (props, ...plugins) => {
|
||||
cell.render = (type, userProps = {}) => {
|
||||
const Comp = typeof type === 'string' ? column[type] : type
|
||||
|
||||
if (!Comp) {
|
||||
if (typeof Comp === 'undefined') {
|
||||
throw new Error(renderErr)
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user