TehShrike / deepmerge

A library for deep (recursive) merging of Javascript objects
MIT License
2.75k stars 216 forks source link

Doesn't play nice with React 19 RC #265

Open AnthonyPaulO opened 1 month ago

AnthonyPaulO commented 1 month ago

In "node_modules/deepmerge/dist/cjs.js" there's a line of code:

var REACT_ELEMENT_TYPE = canUseSymbol ? Symbol.for("react.element") : 60103;

React 19 uses "react.transitional.element" as its REACT_ELEMENT_TYPE, so operations that attempt to check if an object is a react element fails, such as the ReactChildren function "mapIntoArray" which does the following comparison in its switch statement:

`

          case "object":
            switch (children.$$typeof) {
              case REACT_ELEMENT_TYPE:
              case REACT_PORTAL_TYPE:
                invokeCallback = true;
            }

`

Since children.$$typeof is 'react.transitional.element', and deepmerge has its own definition of REACT_ELEMENT_TYPE being "react.element", this fails the check and the function mapIntoArray fails.