isFragment.js 637 B

123456789101112131415161718
  1. import _typeof from "@babel/runtime/helpers/esm/typeof";
  2. var REACT_ELEMENT_TYPE_18 = Symbol.for('react.element');
  3. var REACT_ELEMENT_TYPE_19 = Symbol.for('react.transitional.element');
  4. var REACT_FRAGMENT_TYPE = Symbol.for('react.fragment');
  5. /**
  6. * Compatible with React 18 or 19 to check if node is a Fragment.
  7. */
  8. export default function isFragment(object) {
  9. return (
  10. // Base object type
  11. object && _typeof(object) === 'object' && (
  12. // React Element type
  13. object.$$typeof === REACT_ELEMENT_TYPE_18 || object.$$typeof === REACT_ELEMENT_TYPE_19) &&
  14. // React Fragment type
  15. object.type === REACT_FRAGMENT_TYPE
  16. );
  17. }