Trying to map an object that was returned from a promise, i am using react-router 4 and redux, redux-promise. the data has been returned as a promise but i cant seem to map it. If i remember correctly, the render() returns the renderBanner function and renders it there but i am a little unsure of how to map this data as i want to just grab the img and map it.
edit: example (uses different api but same process)
component file
import React, { Component } from 'react';
import { Grid, Image } from 'react-bootstrap';
// import { bindActionCreators } from 'redux';
import { connect } from 'react-redux';
import { fetchAdverts } from '../actions/adverts_action';
class FullWidthBannerAd extends Component {
componentDidMount(props) {
this.props.fetchAdverts();
}
constructor(props) {
super(props)
// this.state = {
// data: []
// };
console.log('Props Contains:', props);
};
renderBanner(props) {
console.log('renderBanner Contains:', props);
return (
<div>
hello
</div>
)
}
render() {
return (
<Grid>
{this.renderBanner()}
</Grid>
);
}
}
function mapStateToProps(state) {
return {
adverts: state.adverts
};
}
export default connect(fetchAdverts)(FullWidthBannerAd);
promise returned
[,…]
0
:{_id: "57bf06e2ad5f52130098ae1c", sort_order: null, img: "e670cf43-9ed7-45f4-987d-d899af472f4c.jpg",…}
_id:"57bf06e2ad5f52130098ae1c"
img:"e670cf43-9ed7-45f4-987d-d899af472f4c.jpg"