Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to Fix React JS Unused variable like below shown?

I created a new ReactJS app and corded it as below. It doesn’t work. I need const person call into const app, How to do that?

"App.js"

import './App.css';
const person = () => {
  return (
    <>
    <h1>Name : Shashimal</h1>
    <h1>Age : 26</h1>
    <h1>Gender : Male</h1>
    </>
  )
}
const App = () => {
  return (
    <div className="App">
       <person />
    </div>
  );
}
export default App;

error code shown terminal

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Search for the keywords to learn more about each warning.
To ignore, add // eslint-disable-next-line to the line before.

WARNING in [eslint]
src\App.js
  Line 3:7:  'person' is assigned a value but never used  no-unused-vars

webpack compiled with 1 warning

>Solution :

The problem is that when it comes to React components you must use component names first word capitalized. So, make person to Person

import './App.css';

const Person = () => {
  return (
    <>
      <h1>Name : Shashimal</h1>
      <h1>Age : 26</h1>
      <h1>Gender : Male</h1>
    </>
  );
};
const App = () => {
  return (
    <div className="App">
      <Person />
    </div>
  );
};

export default App;
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading