React Redux: Can View Props In Browser Console, But Return Undefined When Rendered
I am having a problem rendering the props value in react. I have added data fetched from an API to a redux store, and then mapped the state to my App component. The data shows up
Solution 1:
Reason is, you are fetching the data from api, until you didn't get the response {this.props.products.item}
will be undefined, because render
will get executed before you get the response. So either you need to hold the rendering by using some bool until you didn't get the response or put the check, like this:
{this.props.products.items && this.props.products.items[0].title}
Post a Comment for "React Redux: Can View Props In Browser Console, But Return Undefined When Rendered"