Home > database >  React says 'myComponent' is defined but never used, but still I am using <myComponent&g
React says 'myComponent' is defined but never used, but still I am using <myComponent&g

Time:03-07

Today I have created my basic react app where I have created a new component called 'myComponent.js' and later on I tried to import it into index file using import statement. When I use myComponent in the file to render it on screen and also a warning pops out saying 'myComponent' is defined but never used.

CodePudding user response:

The first letter should be capitalized. You should do updates to use <MyComponent/> instead

CodePudding user response:

Fix for this problem is whenever we make react components we must make sure that they start with captial letter. Like 'MyComponent' not 'myComponent'. This solved my problem.

Is there any other problem that could happen or any other fix?

  • Related