Skip to content

Add React.isFragment api for verifying Fragment #12038

Closed
@zheeeng

Description

@zheeeng

Do you want to request a feature or report a bug?

I want to request a feature.

What is the current behavior?

We have no API to verify a ReactNode is a React 16 Fragment. Though now we can use React.isValidElement(instance) && typeof instance.type === 'symbol' to distinguish it. It's verbose and seems uncertianly right.

What is the expected behavior?

Add api:

React.isFragment(object)

Verifies the object is a React.Fragment. Returns true or false.

Which versions of React, and which browser / OS are affected by this issue? Did this work in previous versions of React?

React 16.2

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions