Closed cbbfcd closed 1 year ago
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.
Sounds like a react-is
sort of thing
@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.
I did some random googling and found that many third libraries support isFragment
internally, but for developers, it can be a long wait
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
That internalised _isFragment
function should pass as is. But seems like tackling #3899 makes sense regardless.
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;
}
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?