How to use read this Array in ReactJS complex

4144 views arrays
2

How to use read this Array in ReactJS ->

0: {codes: Array(4), arguments: Array(3), defaultMessage: "not a well-formed email address", objectName: "userVO", field: "email", …} Example IMage

answered question

1 Answer

7

Not sure exactly if this is what you're asking for but in ES6 you can use the .map function to traverse an array and return it's values:

const arr = {codes: Array(4), arguments: Array(3), defaultMessage: "not a well-formed email address", objectName: "userVO", field: "email"}

arr.map(item => {
  return (
    <div>
      <p>{item.codes}</p>
      <p>{item.defaultMessage}</p>
    </div>
  );
})

posted this

Have an answer?

JD

Please login first before posting an answer.