I would like to know how can I can generate components from a variable which stores an array of strings, with a loop (or something similar). For example, I have an array:
const arr = ['Hello', 'Awesome', 'Stack','Over','Flow', 'Have', 'A', 'Nice', 'Day'];
and I wrote this method:
function renderT() {
return arr.map(obj => {
<Text>{obj}</Text>;
});
}
and I then call it in the return statement of my render() method:
return (
<View style={styles.row}>{renderT()}</View>
)
As result I don't have any error or text on the screen. I tried to use different kind of loop for, forEach, map and it didn't work. Could you please point me or suggest me the right way how can I implement it?
arrdefined? 2. replace the curly braces in themapfunction so it will actually return something 3. add akeyprop to eachText