From ab12816799de4c9ad2a970a15c9cc8925010cc7d Mon Sep 17 00:00:00 2001 From: Thomas Rich Date: Thu, 5 Sep 2019 13:45:03 -0700 Subject: [PATCH] Fix 6.10 remounting/double click issue (#1499) Fixes https://github.com/tannerlinsley/react-table/issues/1336 (or at least fixes my issue with double click not working) --- src/utils.js | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/src/utils.js b/src/utils.js index 2bac825..2b5a313 100644 --- a/src/utils.js +++ b/src/utils.js @@ -204,5 +204,34 @@ function isSortingDesc (d) { } function normalizeComponent (Comp, params = {}, fallback = Comp) { - return typeof Comp === 'function' ? : fallback + return typeof Comp === 'function' ? ( + isReactComponent(Comp) ? ( + + ) : ( + Comp(params) + ) + ) : ( + fallback + ) +} + +function isClassComponent (component) { + return !!(( + typeof component === 'function' && + !!component.prototype.isReactComponent + )) +} + +function isFunctionComponent (component) { + return !!(( + typeof component === 'function' && + String(component).includes('return React.createElement') + )) +} + +function isReactComponent (component) { + return !!(( + isClassComponent(component) || + isFunctionComponent(component) + )) }