I am new to react. I am working on building a simple contact list application to display the contact's name, email and we will store a catchphrase of a contact. We will make use of this, it contains a JSON dump of data needed for our contact list application. I have 2 files statushelper.js and shapes.js
Below is the statushelper.js
import React, {Component} from 'react';
import Shapes from './Shapes';
class StatusHelper extends Component {
constructor() {
super();
this.state = {
contacts: []
};
}
componentDidMount() {
fetch('http://jsonplaceholder.typicode.com/users')
.then(res => res.json())
.then((data) => {
this.setState({contacts: data})
})
.catch(console.log)
}
render () {
return (
<Shapes contacts={this.state.contacts} />
);
}
}
export default StatusHelper;
Shapes.js
import React from 'react'
const Shapes = ({ contacts }) => {
return (
<div style={{text_align: 'center'}}>
<h1>Contact List</h1>
{contacts.map((contact) => (
<div className="card">
<div className="card-body">
<h5 className="card-title">{contact.name}</h5>
<h6 className="card-subtitle mb-2 text-muted">{contact.email}</h6>
<p className="card-text">{contact.company.catchPhrase}</p>
</div>
</div>
))}
</div>
)
};
export default Shapes
When I run statushelper.js file I am running into the following errors
'contacts' is missing in props validation react/prop-types
Missing "key" prop for element in iterator react/jsx-key
any suggestions?