As I see React.isFragment
is only a proposal for the moment: https://github.com/facebook/react/issues/12038
Is there a workaround to do something like
if (child instanceof React.Fragment) {
...
}
until that API is available.
Temporary solution that works for me:
const isReactFragment = child => {
try {
return child.type.toString() === React.Fragment.toString();
} catch (e) {
return false;
}
};