I'm new to React Native, and I wonder why my code isn't working. I know thorugh console.logging that my output array is full with the correct data, but for some reason in the return when I try to write out the output it doesnt seem to writing anything to the mobile screen. I wonder why that might be.
const ChampionScreen = () => {
const [champions, setChampions] = useState([]);
var output = [];
useEffect(() => {
AxiosService.getChampions()
.then(data => {
setChampions(data);
var champarr =[];
Object.keys(champions).forEach(function(key){
champarr.push(champions[key]);
})
for(let i = 0; i < champarr.length;i++){
let champion = JSON.parse(JSON.stringify(champarr[i]));
var tempItem = (
<View key={i}>
<Text>{champion.name}</Text>
</View>
);
output[i] = (tempItem);
}
}).catch(err => console.error(err))
},[])
return (
<ScrollView>
<View>
{output}
</View>
</ScrollView>
)
}