in this page : https://api.exchangeratesapi.io/latest i can not render rates in text component , how to show rates in react native
async componentDidMount(){
const coin = await Fetch.fetchCoins();
this.setState({coin});
}
{this.props.shop.map((item)=>{
return(
<View key={item.base}>
<Text>{item.date}</Text>
<Text>{item.rates}</Text>
</View>
)
})
}
Seeing as rates
is an object, I would recommend adding a function approximately something like the following:
renderRates = (rates) => {
let rows = [];
Object.keys(rates).forEach(key => {
rows.push(<Text>{key + ' ' + rates[key]}</Text>)
});
return rows;
}
and then replacing <Text>{item.rates}</Text>
with {this.renderRates(this.coin.rates)}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.