From aa2835766a7a34f70cd6b579628e4f7e820970ab Mon Sep 17 00:00:00 2001 From: Roman Komarov Date: Thu, 30 Jul 2020 16:39:53 +0200 Subject: [PATCH] fix: Use references to renderers instead of inline functions (#2584) 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. --- src/publicUtils.js | 5 ++++- src/utils.js | 6 +++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/publicUtils.js b/src/publicUtils.js index 27302f8214..5d7cf1fd9e 100644 --- a/src/publicUtils.js +++ b/src/publicUtils.js @@ -6,8 +6,11 @@ export const actions = { init: 'init', } +export const defaultRenderer = ({ value = '' }) => value; +export const emptyRenderer = () => <> ; + export const defaultColumn = { - Cell: ({ value = '' }) => value, + Cell: defaultRenderer, width: 150, minWidth: 0, maxWidth: Number.MAX_SAFE_INTEGER, diff --git a/src/utils.js b/src/utils.js index 28bc61c5e6..ae5d48ca4e 100755 --- a/src/utils.js +++ b/src/utils.js @@ -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) { @@ -71,8 +71,8 @@ export function decorateColumn(column, userDefaultColumn) { } Object.assign(column, { // Make sure there is a fallback header, just in case - Header: () => <> , - Footer: () => <> , + Header: emptyRenderer, + Footer: emptyRenderer, ...defaultColumn, ...userDefaultColumn, ...column,