React version: 18.3.1 / 19.2.5 (both affected)
Steps To Reproduce
- Install
react@18 and react@19 alongside react-is@19 (using npm package aliases)
- Create an element with each React version
- Call
isElement() from react-is@19 on each element
Link to code example: https://codesandbox.io/p/devbox/f4ch33
The current behavior
react-is@19 returns false for elements created by React 17/18.
React 19 changed $$typeof from Symbol(react.element) to Symbol(react.transitional.element). react-is@19 only checks for the new symbol and does not recognise the old one.
react-is@19 .isElement() on react@19 element: true
react-is@19 .isElement() on react@18 element: false ← broken
This breaks any tool that upgrades to react-is@19 while its users are still on React 17/18. We hit this in jestjs/jest#15402 - pretty-format's ReactElement plugin silently falls back to printing elements as plain objects.
The expected behavior
react-is@19 should recognise elements created by React 17 and 18. Alternative is what I do in jestjs/jest#16123 (use both react-is@18 and react-is@19) but that feels like an unnecessary burden to place on the community
(Disclaimer - Claude Code wrote the reproduction and this OP 😀)
React version: 18.3.1 / 19.2.5 (both affected)
Steps To Reproduce
react@18andreact@19alongsidereact-is@19(using npm package aliases)isElement()fromreact-is@19on each elementLink to code example: https://codesandbox.io/p/devbox/f4ch33
The current behavior
react-is@19returnsfalsefor elements created by React 17/18.React 19 changed
$$typeoffromSymbol(react.element)toSymbol(react.transitional.element).react-is@19only checks for the new symbol and does not recognise the old one.This breaks any tool that upgrades to
react-is@19while its users are still on React 17/18. We hit this in jestjs/jest#15402 -pretty-format'sReactElementplugin silently falls back to printing elements as plain objects.The expected behavior
react-is@19should recognise elements created by React 17 and 18. Alternative is what I do in jestjs/jest#16123 (use bothreact-is@18andreact-is@19) but that feels like an unnecessary burden to place on the community(Disclaimer - Claude Code wrote the reproduction and this OP 😀)