{cartItems.map((item, pos) =>{
return (
<div className="item-container" key ={pos}>
<Item {...item } setIsLoading={setIsLoading} />
</div>
)
})}
when I try to call setIsLoading in Item, it gives me an error saying that
"Uncaught TypeError: setIsLoading is not a function"
I am also not very sure if the header was written correctly:
const Item = (product, setIsLoading) => {
//....
setIsLoading(true);
}
it was working fine before I added setIsLoading. I am a bit confused about what the problem is.
CodePudding user response:
Props in a component is only an object You can see the documentation here
But for now you can destructure the props
const Item = ({setIsLoading, ...product}) => {
//....
setIsLoading(true);
}