I'm finding it hard to export or pass the variable with the names objHead and objDetails from this component to another component so that I can use it there.
is there like a keyword I can use in react for it just like the way module.exports is in Nodejs?
function Add(prop){
//function to store the detail and title prop into an object
const AddCart = () => {
const obj = {
head:prop.title,
body:prop.details
}
const objHead = obj.head;
const objDetails = obj.body;
}
return(
<div>
<div className="box">
<h5 id="AddHead">Add header</h5>
<p>{prop.title}</p>
<p>{prop.details}</p>
</div>
<button className="btn" onClick={AddCart}>Add to cart</button>
<hr></hr>
</div>
)
}
export default Add;