Skip to content

Commit

Permalink
fix: fix column-ordering example
Browse files Browse the repository at this point in the history
  • Loading branch information
tannerlinsley committed Aug 28, 2019
1 parent e7722b1 commit 0486c5c
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 20 deletions.
26 changes: 12 additions & 14 deletions examples/column-ordering/src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,20 +79,18 @@ function Table({ columns, data }) {
))}
</thead>
<tbody>
<AnimatePresence>
{rows.slice(0, 10).map(
(row, i) =>
prepareRow(row) || (
<tr {...row.getRowProps()}>
{row.cells.map((cell, i) => {
return (
<td {...cell.getCellProps()}>{cell.render('Cell')}</td>
)
})}
</tr>
)
)}
</AnimatePresence>
{rows.slice(0, 10).map(
(row, i) =>
prepareRow(row) || (
<tr {...row.getRowProps()}>
{row.cells.map((cell, i) => {
return (
<td {...cell.getCellProps()}>{cell.render('Cell')}</td>
)
})}
</tr>
)
)}
</tbody>
</table>
<pre>
Expand Down
4 changes: 2 additions & 2 deletions src/hooks/useTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,8 @@ export const useTable = (props, ...plugins) => {

// Make the headerGroups
const headerGroups = React.useMemo(
() => makeHeaderGroups(flatColumns, columns, defaultColumn),
[columns, defaultColumn, flatColumns]
() => makeHeaderGroups(flatColumns, defaultColumn),
[defaultColumn, flatColumns]
)

const headers = React.useMemo(() => headerGroups[0].headers, [headerGroups])
Expand Down
6 changes: 2 additions & 4 deletions src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react'

const columnFallbacks = {
Header: () => null,
Cell: ({ cell: { value = '' } }) => value,
Cell: ({ cell: { value = '' } }) => String(value),
show: true,
}

Expand Down Expand Up @@ -79,11 +79,9 @@ export function decorateColumnTree(columns, defaultColumn, parent, depth = 0) {
}

// Build the header groups from the bottom up
export function makeHeaderGroups(flatColumns, columns, defaultColumn) {
export function makeHeaderGroups(flatColumns, defaultColumn) {
const headerGroups = []

const maxDepth = findMaxDepth(columns)

// Build each header group from the bottom up
const buildGroup = (columns, depth) => {
const headerGroup = {
Expand Down

0 comments on commit 0486c5c

Please sign in to comment.