I have a error of Module not found. I think that such error is because of lack of a file or directory .However I have checked more than 30 times at that particular location and even for typos ,I don't think i have any mistake here.
Here is my code for DishdetailComponent.js
import React,{Component} from 'react';
import { Card, CardImg, CardImgOverlay, CardTitle, CardBody, CardText} from 'reactstrap';
class Dishdetail extends Component{
constructor(props){
super(props);
}
render(){
if(this.props.dish!=null){
return(
<div className="container">
<div className="row">
<div className="col-12 col-md-5 m-1">
<Card>
<CardImg width="100%" object src={dish.image} alt={dish.name} />
<CardBody>
<CardTitle>{dish.name}</CardTitle>
<CardText>{dish.description}</CardText>
</CardBody>
</Card>
</div>
</div>
</div>
)
}
else{
return <div></div>
}
}
}
export default Dishdetail;
I am calling this component from Menucomponent.js file.It has following code:
import React,{Component} from 'react';
import { Card, CardImg, CardImgOverlay, CardTitle, CardBody, CardText} from 'reactstrap';
import Dishdetail from './Components/DishdetailComponent';
class Menu extends Component{
constructor(props){
super(props);
this.state={
selectedDish:null
};
}
render() {
const menu = this.props.dishes.map((dish) => {
return (
<div key={dish.id} className="col-12 col-md-5 m-1">
<Card onClick={()=>this.onDishSelect(dish)}>
<CardImg width="100%" object src={dish.image} alt={dish.name} />
<CardImgOverlay>
<CardTitle>{dish.name}</CardTitle>
</CardImgOverlay>
</Card>
</div>
);
});
return (
<div className="container">
<div className="row">
{menu}
</div>
{/* {this.renderDish(this.state.selectedDish)} */}
<Dishdetail dish={this.state.selectedDish}/>
</div>
);
}
}
export default Menu;
The hierarchy of my code follows,
-src(folder)
-Components(sub-folder)
-menucomponent.js
-DishdetailComponent.js
The file I want to import to and the file which will recieve are in same folder Components.
Menucomponent.jsfile it must beimport Dishdetail from './DishdetailComponent';