wix-incubator / vscode-glean

The extension provides refactoring tools for your React codebase

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Wrap new component code with fragment only if needed

chiptus opened this issue · comments

Thank you for this extension, for a long time I wanted one like this (I started creating one, but didn't have the time to make it more production ready).
Now for the bug/feature-request:

Not always I will need a fragment (<>) wrapping my new component. It should wrap only when there's more than one element in the root

@chiptus Glad you liked it! Thank you! As for the idea - I agree completely!
The problem here is that Babel doesnt know how to parse multiline JSX, and throws an error. Thats why I wrap it by default.
The naive solution would be to have a try-catch statement, with a fallback in the catch statement. But that pretty bad.

@chiptus i've created a naive implementation for now
24ff2b0
Check it out in v4.0.7