Skip to content
Advertisement

setting state within nested response

I am building a react app and I am setting the state with api of nested response of nested state But the state is not setting the way I want.

response that is receiving from api

JavaScript

App.js

JavaScript

What is the problem ?

Images are not showing after Title. I am trying to show all images in BlogList class of every blog.

I have also tried using (in BlogList class)

JavaScript

But it showed me

this.props.images.map is not a function.

then I think the problem is with setting state of images (I may be wrong).

When I tried to print this.props.images then it is showing

JavaScript

I am new in react, Any help would be much Appreciated. Thank You in Advance

Advertisement

Answer

this.props.images is an array and hence you can’t use {this.props.images} directly. Other wise you will get an error like this “Objects are not valid as a React child. If you meant to render a collection of children, use an array instead”

You have to use something like this

JavaScript
Advertisement