Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

244
Visualizações
src\App.js 'nav' is defined but never used no-unused-vars

Can't create navbar in reactjs.

App.js

import './App.css';
import '../node_modules/bootstrap/dist/css/bootstrap.min.css'
import Home from './Routes/Home'
import About from './Routes/About'
import Contact from './Routes/Contact'
import {BrowserRouter, Routes, Route} from 'react-router-dom'
import nav from './nav'


function App() {
  return (
    <div className="App">
      
      <BrowserRouter>
      <nav/>
      
      <Routes>
      <Route>
      
        <Route exact path="/" element={<Home/>} />
        <Route exact path="/about" element={<About/>} />
        <Route exact path="/contact" component={<Contact/>} />
      </Route>
      </Routes>
      </BrowserRouter>
      
    </div>
  );
}

export default App;

nav.js

import React from 'react'
import {Link} from 'react-router-dom'

function nav(){
    return <div>
      <nav>
          <Link to="/" >Home</Link>
          <Link to="/about" >About</Link>
          <Link to="/contact" >Contact</Link>
      </nav>

    </div>
}

export default nav

The terminals shows "Compiled with warnings. src\App.js Line 7:8: 'nav' is defined but never used no-unused-vars
Search for the keywords to learn more about each warning.
To ignore, add // eslint-disable-next-line to the line before.
"

about 4 years ago · Juan Pablo Isaza
3 Respostas
Responde à pergunta

0

<nav/> is a valid HTML tag, so ESLint thinks your JSX is referencing that HTML tag, and not the variable that holds the component you imported.

I recommend renaming your component to be Nav to remove all ambiguity.

about 4 years ago · Juan Pablo Isaza Relatório

0

This happenes because your compiler does not recognize JSX syntax as being used.

So, You have to install: npm install eslint-plugin-react --save-dev

Then in your .eslintrc.json file you should add react/jsx-uses-react

about 4 years ago · Juan Pablo Isaza Relatório

0

From the docs,

A variable foo is considered to be used if any of the following are true:

It is called (foo()) or constructed (new foo())

It is read (var bar = foo)

It is passed into a function as an argument (doSomething(foo))

It is read inside of a function that is passed to another function (doSomething(function() { foo(); }))

So that, said, you maybe be missing some parsing so your valid jsx and reactjs syntax can be valid eslint syntax:

eslint-plugin-react

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda