I have a nested array of "credits"
const credits = [
{
id: 1,
heading: 'Test Organisation',
credits: [
{id: 1, text: 'Joe Bloggs'},
{id: 2, text: 'Jane Bloggs'},
]
},
....
];
I am wanting to print each "header" in a <Text> element, and then subsequently each of their "credits" in a <Text> element.
I have looked at the following already answered questions on how to achieve this, but one is for ReactJS and uses HTML and the other that uses React Native outputs only the opening tag of a view:
- Cannot Render Nested Maps In ReactJS
- How to use if else condition inside nested map function in react-native?
I am being told there is a syntax error as it is expecting a close parentheses after the end of the first <Text> element.
Here is what I have:
render() {
return (
<ScrollView style={styles.container}>
<View style={styles.centredHighlightHeaderWrapper}>
<Text style={styles.centredHighlightHeader}>
Credits
</Text>
</View>
{
credits.map(item => (
<Text style={styles.centredHeader}>{item.heading}</Text>#Unexpected token -- js error says expecting "," - phpstorm says expecting ")"
{
item.credits.map(credit => (
<Text style={styles.name}>{credit.text}</Text>
))
}
))
}
</ScrollView>
);
}