Fix renderer functions for blank headers

This commit is contained in:
tannerlinsley 2019-07-25 13:37:58 -06:00
parent b2ed18696f
commit ea79cd8388
2 changed files with 8 additions and 9 deletions

View File

@ -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

View File

@ -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)
}