Skip to content

Commit

Permalink
fix: Use references to renderers instead of inline functions (#2584)
Browse files Browse the repository at this point in the history
In order to be able to check if a column has a default renderer, we need them to be exposed constants instead of inline functions.
  • Loading branch information
kizu committed Jul 30, 2020
1 parent d6ba4d4 commit aa28357
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
5 changes: 4 additions & 1 deletion src/publicUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,11 @@ export const actions = {
init: 'init',
}

export const defaultRenderer = ({ value = '' }) => value;
export const emptyRenderer = () => <>&nbsp;</>;

export const defaultColumn = {
Cell: ({ value = '' }) => value,
Cell: defaultRenderer,
width: 150,
minWidth: 0,
maxWidth: Number.MAX_SAFE_INTEGER,
Expand Down
6 changes: 3 additions & 3 deletions src/utils.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react'
import { defaultColumn } from './publicUtils'
import { defaultColumn, emptyRenderer } from './publicUtils'

// Find the depth of the columns
export function findMaxDepth(columns, depth = 0) {
Expand Down Expand Up @@ -71,8 +71,8 @@ export function decorateColumn(column, userDefaultColumn) {
}
Object.assign(column, {
// Make sure there is a fallback header, just in case
Header: () => <>&nbsp;</>,
Footer: () => <>&nbsp;</>,
Header: emptyRenderer,
Footer: emptyRenderer,
...defaultColumn,
...userDefaultColumn,
...column,
Expand Down

1 comment on commit aa28357

@vercel
Copy link

@vercel vercel bot commented on aa28357 Jul 30, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.