I’m having some issues using react.
When I’m trying to write something like:
import React, { useState } from 'react';
function Navbar() {
<>
nav.navbar
</>;
}
I cant seem to get the jsx typing to work
What am I missing? normally this should have turned into:
<nav className=navbar></nav>
but its not doing anything.
Can anyone help me with this?
I tried installing some extensions that should support it, reinstall node and stuff
3
Answers
No it will not automatically show. You are confusing it with emmet. That will show in editor if you are using emmet. Otherwise you have to write it. Update the code like this:-
In your Visual Studio Code, go to Settings and search for emmet.
In the results, you will find a tab that reads:
There, you should add in the list the items from the description above, as such:
You can also achieve this by editing your
settings.json
file directly and adding this:You are trying to use a tool called Emmet, this allows you to enter abbreviations which are then auto expanded to the desired code.
As it is not working it would seem that Emmet is either not installed, or not configured for you code editor.
You will need to download, install and configure it before the abbreviations will work.
You haven’t mentioned which editor you are using so the best advice we can give is to go to the Emmet homepage, where it will show if it is available for your editor and how to get it working.
https://emmet.io/
Alternatively, the code editors website will likely have the same information available as Emmet is widely used.
VSCode is probably the most commonly used editor right now, it comes with Emmet preinstalled but you need to update the configuration to use Emmet in jsx or tsx files.
In settings, search for Emmet and then in the
Include Languages
section add: