-1

I have a component called "contactList" and i want to render it inside of another component called "App" but it gives me an error that say "contactList is defined but never used no-unused-vars"

import React, { Component } from 'react';
import './App.css';

class contactList extends Component {
  render(){
    const people = [
      {name: "kester"},
      {name: "john"},
      {name: "mary"}
    ]

     return <ol>
      {people.map(person =>(
        <li key={person.name}>{person.name}</li>
      ))}
     </ol>
  }
}

class App extends Component {
  render(){
    return <div className='App'>
    <contactList/>
  </div>
      
    
  }
}

export default App;
1
  • 1
    react components should start with capital letter Commented Sep 2, 2022 at 8:30

2 Answers 2

2

React component name must start with capital letter.

So, you need to rename your conatctList component with ContactList.

Sign up to request clarification or add additional context in comments.

Comments

1

When running your code, I get the following error:

Warning: <%s /> is using incorrect casing. Use PascalCase for React components, or lowercase for HTML elements.%s
contactList

    at contactList
    at div
    at App (<anonymous>:51:11)

Rename your component to ContactList and update the usage to <ContactList/>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.