I am trying to initialize a react hook with an object.
const[cartitems,setcartitems]=useState([{name:"apple",price:900}]);
This is the error that I am getting.
Uncaught Error: Objects are not valid as a React child (found: object with keys {name, price}). If you meant to render a collection of children, use an array instead.
How can I avoid this error?