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

Add React.isFragment api for verifying Fragment #12038

Closed
zheeeng opened this issue Jan 18, 2018 · 9 comments
Closed

Add React.isFragment api for verifying Fragment #12038

zheeeng opened this issue Jan 18, 2018 · 9 comments
Assignees

Comments

@zheeeng
Copy link

zheeeng commented Jan 18, 2018

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

@NE-SmallTown
Copy link
Contributor

NE-SmallTown commented Jan 21, 2018

Is there already some progress on this? If no, maybe I can take this

@aweary
Copy link
Contributor

aweary commented Jan 29, 2018

There is #11279, which implements isFragment along with a number of related introspection utilities.

@NE-SmallTown
Copy link
Contributor

NE-SmallTown commented Jan 30, 2018

@aweary Yep, but looks like seb's abstraction is excessive and dan doesn't approve it? But if you want to merge that later or you just want to tell @zheeeng can copy and use that in their projects, I will be fine to close #12092 :)

@bvaughn
Copy link
Contributor

bvaughn commented Feb 9, 2018

I'm going to take a look into finishing up PR #11279.

@bvaughn bvaughn self-assigned this Feb 9, 2018
@bvaughn
Copy link
Contributor

bvaughn commented Feb 9, 2018

Check out PR #12199

@bvaughn
Copy link
Contributor

bvaughn commented Feb 12, 2018

FYI you can test the new react-is alpha via npm install react-is@next (or yarn add react-is@next)

@zheeeng
Copy link
Author

zheeeng commented Feb 13, 2018

@bvaughn This package is awesome!

@bvaughn
Copy link
Contributor

bvaughn commented Feb 13, 2018

Glad to hear!

@aweary
Copy link
Contributor

aweary commented Apr 7, 2018

Closing, since this API exists in react-is

@aweary aweary closed this as completed Apr 7, 2018
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.

5 participants