Skip to content

Rule suggestion: consistent usage of <React.Fragment> vs <> #156

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

Closed
rherms opened this issue Apr 18, 2018 · 5 comments
Closed

Rule suggestion: consistent usage of <React.Fragment> vs <> #156

rherms opened this issue Apr 18, 2018 · 5 comments

Comments

@rherms
Copy link

rherms commented Apr 18, 2018

Would be nice to have a rule for preferring <React.Fragment> over <>. Would love to try tackling this myself if I have the time.

@jkillian
Copy link
Contributor

Hmm, what's the justification for this @rherms? Just to make things more readable?

@rherms
Copy link
Author

rherms commented Apr 19, 2018

Yeah readability and the fact that fragments are still relatively new so people might not know what <> means.

@suchanlee
Copy link
Contributor

I dont have much of an opinion here. One other advantage of <React.Fragment> vs <> is that <> cannot have attributes so for keyed fragments you need to use <React.Fragment> (https://reactjs.org/blog/2017/11/28/react-v16.2.0-fragment-support.html#keyed-fragments)

Instead of preferring React.Fragment over <>, I think that it could be valuable to be enforce the usage of either one for consistency.

@jrparish
Copy link

I agree that it would be better for the rule to enforce consistency similar to this eslint rule - https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/jsx-fragments.md

@adidahiya adidahiya changed the title Rule for prefer <React.Fragment> over <> Rule suggestion: consistent usage of <React.Fragment> vs <> Jan 15, 2019
@adidahiya
Copy link
Contributor

Closing due to deprecation timeline, see #210

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants