@codecademy/gamut
68.2.268.2.3-alpha.c8dfb9.0
dist/utils/react.js~
dist/utils/react.jsModified+4−2
Index: package/dist/utils/react.js
===================================================================
--- package/dist/utils/react.js
+++ package/dist/utils/react.js
@@ -1,5 +1,6 @@
import { Children, isValidElement } from 'react';
+import { isNullish } from './nullish';
/**
* Recursively extracts plain text content from React children.
*
@@ -28,13 +29,14 @@
return Children.toArray(children).map(child => {
if (typeof child === 'string' || typeof child === 'number') {
return String(child);
}
- if (typeof child === 'boolean' || child == null) {
+ if (typeof child === 'boolean' || isNullish(child)) {
return '';
}
if (/*#__PURE__*/isValidElement(child)) {
- const textContent = child.props.children ?? child.props.text ?? '';
+ const props = child.props;
+ const textContent = props.children ?? props.text ?? '';
return extractTextContent(textContent);
}
return '';
}).filter(Boolean).join(' ');