Wrong import path when copy/pasting JSX between components

I have 3 React components, all in separate files with default export

- Component1.js

- Component2.js

- SharedComponent.js


If I include SharedComponent in Component1 with auto-completion, the correct import is automatically added :


But if I copy/paste ths JSX containing <SharedComponent> into Component2, the wrong import is generated :

Component1.js :

Component2.js :

This bug happen whatever the depth and complexity of the JSX copied, as long as it contained one imported component.


This is clearly a bug. At no point any JSX copied from one file should be considered the defautl export from that file. A the very least in this case, no import should be generated.


I'm still experiencing this bug (or some variation of it) in version 2019.1.1.

One specific example for me is lodash imports: import _ from "lodash";

When I copy code from one file to another that includes usages of lodash (_), and the destination file does not yet have an import for lodash, then an incorrect auto import is added to import _ from the source file.


Please sign in to leave a comment.