'React / Redux: Getting an error of is missing in props validation eslintreact/prop-types
I am getting an issue with my App on certain Lines with the following error:
'Item' is missing in props validationeslintreact/prop-types
From what I have seen, I've installed and Imported the Prop Types via NPM Install and Included an Import at the top of the affected files
The lines in question are "addToCart" and "let itemList = this.props.items.map"
Here is the file in question:
import React, { Component } from 'react';
import { connect } from 'react-redux'
import "materialize-css/dist/css/materialize.min.css";
import { addToCart } from './actions/cartActions'
class Home extends Component{
handleClick = (id)=>{
this.props.addToCart(id);
}
render(){
let itemList = this.props.items.map(item=>{ //Mapping out the Books on the page
return(
<div className="card" key={item.id}>
<div className="card-image">
<img src={item.img} alt={item.title}/>
<span className="card-title">{item.title}</span>
<span to="/" className="btn-floating halfway-fab waves-effect waves-light red" onClick={()=>{this.handleClick(item.id)}}><i className="material-icons">+</i></span>
</div>
<div className="card-content">
<p>{item.desc}</p>
<p><b>Price: £{item.price}</b></p>
</div>
</div>
)
})
return(
<div className="container">
<h3 className="center">Our Books</h3>
<div className="box">
{itemList}
</div>
</div>
)
}
}
//Return this back to App.js to display on the page
const mapStateToProps = (state)=>{
return {
items: state.items
}
}
const mapDispatchToProps = (dispatch)=>{
return{
addToCart: (id)=>{dispatch(addToCart(id))}
}
}
export default connect(mapStateToProps,mapDispatchToProps)(Home)
I have included the fill repo as well in case its not clear if I am missing anything aswell: https://github.com/scb3/pottercart
Thanks in Advance
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
