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

support isFragment #4033

Closed
cbbfcd opened this issue May 29, 2023 · 8 comments · Fixed by #4042
Closed

support isFragment #4033

cbbfcd opened this issue May 29, 2023 · 8 comments · Fixed by #4042

Comments

@cbbfcd
Copy link
Contributor

cbbfcd commented May 29, 2023

As far as I know, there are many projects that use preact to replace react, so it is inevitable that methods such as isFragment will be used in some three-party libraries, but this is not supported by preact. Excuse me, is there any workround? Or consider supporting it?

@marvinhagemeister
Copy link
Member

Neither the react package or the react-dom package seem to export a function called isFragment. Can you share more about where you got it from?

If you ran into a problem with a specific library, feel free to post a reproduction case. Happy to look into that.

@rschristian
Copy link
Member

Sounds like a react-is sort of thing

@cbbfcd
Copy link
Contributor Author

cbbfcd commented May 30, 2023

@marvinhagemeister @rschristian Thanks for such a quick reply.
the problem I encountered is that after replacing react with preact, some third-party libraries, such as ant-design-mobile depend on react-is/isFragment, but this method is not supported by preact/compat, resulting in some components not being able to be run properly, and I believe this problem should be encountered by other developers as well.

@rschristian
Copy link
Member

#3899 (comment)

@cbbfcd
Copy link
Contributor Author

cbbfcd commented May 30, 2023

image

I did some random googling and found that many third libraries support isFragment internally, but for developers, it can be a long wait

@cbbfcd
Copy link
Contributor Author

cbbfcd commented May 30, 2023

For example, I now have the option of raising a pr to ant-design-mobile to be compatible with preact/compat scenarios, but I don't know if they'll accept it, or raising a pr with preact/compat

@marvinhagemeister
Copy link
Member

That internalised _isFragment function should pass as is. But seems like tackling #3899 makes sense regardless.

@cbbfcd
Copy link
Contributor Author

cbbfcd commented May 30, 2023

I'm new to preact, Does it make sense to add isFragment code in preact/compat like this?

export function isFragment(element) {
    if (!isValidElement(element)) return false;
    return element.type === preact.Fragment;
}

@rschristian rschristian linked a pull request Jun 8, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants