No tags are generated when doing .map to a state

-1

In the first image I get the values of laravel and assign them to the state, I clarify that the data is received beforehand.

In the second is where you should generate all the labels and nothing is shown or mark any error in the console as shown in the third image.

I would really appreciate the help.

I call the data of an API in laravel and I assign it to the state, I clarify that when I print in console if the data is displayed

Where I generate the tags generated by the .map

    
asked by Israel Hernández Alfaro 17.05.2018 в 19:31
source

1 answer

1

For putting a but, this.setState is asynchronous, you are doing the console.log right after, but without certainty that the setState has really worked, try this:

...
.then((lista)  => 
  this.setState({ lista },() => {
    console.log(this.state.lista);
  });
})
    
answered by 11.07.2018 в 12:33