Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual studio code: navigate to jsx components

In visual studio code, I would like to be able to navigate to an imported file using ctrl + click.

enter image description here

So far I'm able to do it for javascript files (.js), but it's not working for react files (.jsx)

Here is what my directory structure looks like :

enter image description here

Here are the imports (relative and absolute) in my TestImport.jsx Component :

import DummyTwo from 'components/common/dummy-two/DummyTwo.jsx';
import something from 'components/common/my-file/myFile.js';

import DummyOne from '../common/dummy-one/DummyOne.jsx';
import somethingElse from '../common/my-file/myFile2.js';

And here is my jsconfig.json for vscode

{
  "compilerOptions": {
    "experimentalDecorators": true,
    "baseUrl": "src"
  }
}

Code can be retrieved here: https://github.com/fthebaud/react-boilerplate

Am I missing something in the jsconfig file? regarding the extensions maybe?

like image 343
Fab313 Avatar asked Apr 03 '18 12:04

Fab313


People also ask

How do I navigate between files in VS Code?

Hold Ctrl and press Tab to view a list of all files open in an editor group. To open one of these files, use Tab again to pick the file you want to navigate to, then release Ctrl to open it. Alternatively, you can use Ctrl+Alt+- and Ctrl+Shift+- to navigate between files and edit locations.

What does Ctrl d do in VS Code?

Ctrl+D selects the word at the cursor, or the next occurrence of the current selection. Tip: You can also add more cursors with Ctrl+Shift+L, which will add a selection at each occurrence of the current selected text.

How do you jump to a line in VS Code?

The Go To Line dialog box lets you move to a specific line in the active document. To access this dialog box, open a document for editing, and then select Edit > Go To > Go To Line or press Ctrl+G.

Does Emmet work with JSX?

Emmet does not work in js/jsx files for VS Code 1.62.


1 Answers

You need to add "jsx": "react" to use jsx:

{
  "compilerOptions": {
    "experimentalDecorators": true,
    "baseUrl": "src",
    "jsx": "react"
  }
}

See here for more info about this setting

like image 69
Matt Bierner Avatar answered Oct 07 '22 17:10

Matt Bierner