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

react-in-jsx-scope does not understand fragments #1758

Closed
dantman opened this issue Apr 4, 2018 · 3 comments
Closed

react-in-jsx-scope does not understand fragments #1758

dantman opened this issue Apr 4, 2018 · 3 comments

Comments

@dantman
Copy link

dantman commented Apr 4, 2018

If you use <></> fragment syntax the react-in-jsx-scope rule will not declare React as in scope and the no-unused-vars will fail on the React import.

However React is required for fragment syntax as well as normal element syntax.

import React from 'react';

export default () => <>fragment</>;
@dantman
Copy link
Author

dantman commented Apr 4, 2018

The fix for this appears to be extremely simple. react-in-jsx-scope.js just needs to apply itself to JSXOpeningFragment in addition to JSXOpeningElement.

@ljharb
Copy link
Member

ljharb commented Apr 5, 2018

@dantman that sounds great! However, we'll also want to make sure this change only applies after whichever React version added fragment support.

@bumpah
Copy link

bumpah commented Apr 7, 2018

seems like 16.2.0 -version introduced improved support for fragments.
https://reactjs.org/blog/2017/11/28/react-v16.2.0-fragment-support.html

This was referenced Sep 22, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

3 participants