Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[React 19] react-is isFragment doesn't worked #31688

Closed
JulCyan opened this issue Dec 6, 2024 · 6 comments
Closed

[React 19] react-is isFragment doesn't worked #31688

JulCyan opened this issue Dec 6, 2024 · 6 comments

Comments

@JulCyan
Copy link

JulCyan commented Dec 6, 2024

Project use react version is 17.0.2 and not fixed version for react-is
To fix bug: now I fixed the react-is version to 17.0.2 in package.json , or else it will autoupgrade to the latest version 19.0.0

react-is version 19.0.0

Steps To Reproduce

import { isFragment } from "react-is";  

const fragment = <></>;
console.log("isFragment", isFragment(fragment));

The current behavior

// isFragment false

The expected behavior

// isFragment true
@eps1lon
Copy link
Collaborator

eps1lon commented Dec 6, 2024

Thank you for reporting.

This seems to work in a minimal example: https://codesandbox.io/p/sandbox/magical-rosalind-qkf43m?workspaceId=ws_NXrhLjqHgWvFjhiKcfVFu6

Your version of react-is is probably not matching the version of React you're using. react-is must always match the version of react. Otherwise it may not work correctly.

@JulCyan
Copy link
Author

JulCyan commented Dec 10, 2024

@eps1lon
Sorry, I just seen, wish not too late, this is an example: https://codesandbox.io/p/sandbox/react-19-isfragment-forked-plwtlh
react-is version is >=17.0.2, like in my son project package, it can be use is react18 project and react17 project as dep
and anohter example, react-is version is <19.0.0 :https://codesandbox.io/p/sandbox/react-19-isfragment-forked-fytjp8
Before 19.0.0 released, it's all working, but now the first example is false, of course I can fixed react-is version in my project, but I think it's not necessary
up to you, If this's not a bug, close it, and thanks for your help

@Mathias-S
Copy link

@JulCyan "react-is": ">=17.0.2" means that you are using the latest version of react-is, which is 19.0.0.

But you are using react 17.0.2. As eps1lon says, you must match your React version. If you change react-is to version "17.0.2" it will work.

@JulCyan
Copy link
Author

JulCyan commented Dec 10, 2024

@Mathias-S See my two examples, on <19.0.0, It means before released 19.0.0, I can not match, of course I know what happened, But It seems a bug, I already accepted this propose, And eps1lon can close it

@JulCyan JulCyan closed this as completed Dec 10, 2024
@JulCyan JulCyan reopened this Dec 11, 2024
@zombieJ
Copy link
Contributor

zombieJ commented Dec 12, 2024

react do the break change of $$typeof, which means when use React 19, the react-is must be the React 19.
But the deps lib which support React 18 is still using the react-is@18.x, so it will never work together if deps lib use old version react-is.

I guess the best way is not to use react-is if need compatible with both 19 or 18 blew and copy the code to realize self.

@JulCyan
Copy link
Author

JulCyan commented Dec 12, 2024

@zombieJ Thank you for your advice. I got the answer I wanted.
If you would like, I want to know how to get this info
Find the break change Logs or looking for this source code?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants