Pass 2D array from this.setState() in React

Viewed 14

Let's say i have this 2d array :

let cart =[
["Corn", "Potato", "Radish"],
["Tomato", "Graphes", "Mango"],
];

which is diaplayed inside JSX like this:

<div>
  {cart.map((items, index) => {
    return (
      <ol>
        {items.map((subItems, sIndex) => {
          return <li> {subItems} </li>;
        })}
      </ol>
    );
  })}
</div>

But in my project, the 2D array named "r" is inside setState():

getResult(value) {

    let r = value;

    this.setState({
        resultToJSX: r
    });
}

How can i pass it to JSX from this.setState ?

Thanks for the support here !

1 Answers

All your state properties in the this.state object.

this.state.resultToJSX
Related