mirror of
https://github.com/gosticks/react-table.git
synced 2026-08-12 04:50:20 +00:00
fix: better flexRender utility (supports JSX elements now)
This commit is contained in:
@@ -304,8 +304,8 @@ function Table({ columns, data, updateMyData, disablePageResetOnDataChange }) {
|
||||
disablePageResetOnDataChange,
|
||||
},
|
||||
useFilters,
|
||||
useSortBy,
|
||||
useGroupBy,
|
||||
useSortBy,
|
||||
useExpanded,
|
||||
usePagination,
|
||||
useRowSelect
|
||||
|
||||
+16
-4
@@ -265,10 +265,22 @@ export function getElementDimensions(element) {
|
||||
}
|
||||
|
||||
export function flexRender(Comp, props) {
|
||||
if (typeof Comp === 'function' || typeof Comp === 'object') {
|
||||
return <Comp {...props} />
|
||||
}
|
||||
return Comp
|
||||
return isReactComponent(Comp) ? <Comp {...props} /> : Comp
|
||||
}
|
||||
|
||||
function isClassComponent(component) {
|
||||
return (
|
||||
typeof component === 'function' &&
|
||||
!!Object.getPrototypeOf(component).isReactComponent
|
||||
)
|
||||
}
|
||||
|
||||
function isFunctionComponent(component) {
|
||||
return typeof component === 'function'
|
||||
}
|
||||
|
||||
function isReactComponent(component) {
|
||||
return isClassComponent(component) || isFunctionComponent(component)
|
||||
}
|
||||
|
||||
export const mergeProps = (...groups) => {
|
||||
|
||||
Reference in New Issue
Block a user