Reputation: 87
Can someone tell me why I keep getting this error:
Text string must be rendered within a component
I've taken out portions of the API key.
Here is my code:-
componentDidMount() {
fetch(
`https://api.nomics.com/v1/currencies/ticker?key=11300ce692510973c&ids&interval=5m,30d&convert=GBP&per-page=100&page=1`
).then((response) => response.json())
.then((data) => {
const ndata = data;
const test = data.map((element) => element);
this.setState({ new: test }); })}
render() {
const test = this.state.new.map((e)=>{return(<SvgUri width="10%" height="10%" source={{uri:e.logo_url}}/>)})
return (
<View>{test}</View>
)
}
}
Upvotes: 0
Views: 99
Reputation: 76
try doing this like this.
{ `test.map(logo => logo)` }Because here test
const test = this.state.new.map((e)=>{return(<SvgUri width="10%" height="10%" source={{uri:e.logo_url}}/>)})
;
returns a array of svg
Upvotes: 0
Reputation: 153
You have to wrap test
in a Text
component if it ended up having a type string
. In react native, you can only put text within a Text
component
<View>
<Text>{test}</Text>
<View>
Upvotes: 1