Render from object values – React js Code Answer

Hello Developer, Hope you guys are doing great. Today at Tutorial Guruji Official website, we are sharing the answer of Render from object values – React js without wasting too much if your time.

The question is published on by Tutorial Guruji team.

I have this response object from an api, and I want to loop it and render it as if it was a normal array, how can I render tshirt, jeans and furniture? I will not like to render the value of sneakers, Any suggestion?

const items = {
        tshirt: "Model TS",
        jeans: "ModelXW",
        sneakers: "indcdsc54",
        furniture: "Table31S"
    };

{Object.keys(items).map=>{i => 
  <Card>
 {items[key]}
  </Card>
 }
}

Answer

Try this one implementation line:

{Object.entries(items).filter(v => v[0] !== 'sneakers').map((v, idx) => <Card key={idx}>v[1]</Card>)}
We are here to answer your question about Render from object values – React js - If you find the proper solution, please don't forgot to share this with your team members.

Related Posts

Tutorial Guruji