If I convert innerHTML part to that:
[object Object][object Object][object Object][object Object]
Where I am making mistake? and how can I push to front this json data with cards?
Example json data
Answer:Just remove the
document.getElementById('cards').innerHTML +=. You don’t want that. ReactJS should do the DOM update. And, you should not return from the
fetchfunction. Create a state, and you can use it to render the
JSX..Here is the properly structured
Functional Componentfor you.
useEffecthook to fetch the items when the component is mounted on
DOM. And we are verifying if the
itemobject is not empty before rendering
If you have better answer, please add a comment about this, thank you!