D
D
DonorOfLove2022-02-16 08:29:36
React
DonorOfLove, 2022-02-16 08:29:36

How to draw an object in react?

There is an array of the form:

[ {helm: {}}, {arm: {…}} ]
I run through it with a map and get objects of the form
{helm:{def:1,hp:2}
that need to be inserted into the ul in the form: I
<li>{key + ':' + value}</li>
almost managed to do this as follows:

function showStats() {
        for (let item in items) {
            for (let stat in items[item]) {
                return <li>{stat + ':' + items[item][stat]}</li>
            }
        }
    }

but as expected, the function only returns the first value of item and breaks on return. How to draw the object correctly in this case?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question