diff --git a/src/Table.tsx b/src/Table.tsx index eb7a1994e..51383a158 100644 --- a/src/Table.tsx +++ b/src/Table.tsx @@ -61,7 +61,7 @@ import BodyContext from './context/BodyContext'; import Body from './Body'; import useColumns from './hooks/useColumns'; import { useLayoutState, useTimeoutLock } from './hooks/useFrame'; -import { getPathValue, mergeObject, validateValue, getColumnsKey } from './utils/valueUtil'; +import { getPathValue, validateValue, getColumnsKey } from './utils/valueUtil'; import ResizeContext from './context/ResizeContext'; import useStickyOffsets from './hooks/useStickyOffsets'; import ColGroup from './ColGroup'; @@ -226,16 +226,11 @@ function Table(props: TableProps mergeObject>(components, {}), - [components], - ); - const getComponent = React.useCallback( (path, defaultComponent) => - getPathValue>(mergedComponents, path) || + getPathValue>(components || {}, path) || defaultComponent, - [mergedComponents], + [components], ); const getRowKey = React.useMemo>(() => { @@ -811,15 +806,7 @@ function Table(props: TableProps( - ...objects: Partial[] -): ReturnObject { - const merged: Partial = {}; - - /* eslint-disable no-param-reassign */ - function fillProps(obj: object, clone: object) { - if (clone) { - Object.keys(clone).forEach(key => { - const value = clone[key]; - if (value && typeof value === 'object') { - obj[key] = obj[key] || {}; - fillProps(obj[key], value); - } else { - obj[key] = value; - } - }); - } - } - /* eslint-enable */ - - objects.forEach(clone => { - fillProps(merged, clone); - }); - - return merged as ReturnObject; -} - export function validateValue(val: T) { return val !== null && val !== undefined; } diff --git a/tests/Table.spec.js b/tests/Table.spec.js index 8b1df9ca2..6bc5b80dc 100644 --- a/tests/Table.spec.js +++ b/tests/Table.spec.js @@ -596,6 +596,21 @@ describe('Table.Basic', () => { errSpy.mockRestore(); }); }); + + it('not crash', () => { + const Looper = React.forwardRef(() => ); + Looper.looper = Looper; + + mount( + createTable({ + components: { + body: { + cell: Looper, + }, + }, + }), + ); + }); }); it('align column', () => {