I tried to get only first element [0] of array and print in UI.
I will get only first lesson in the array and then print.
{route.params.Lessons.map((lessons) => {
return (
<View>
<Text style={styles.lessonTitle}>Lesson 1</Text>
<Text style={styles.lessonDescription}>{lessons.lessonName}</Text>
</View>
)
})}
Thanks
>Solution :
If you only want to display only one element of array, you don’t need to use the .map() function
You can try this instead
const lesson1 = route.params.Lessons[0]
return (
<View>
<Text style={styles.lessonTitle}>Lesson 1</Text>
<Text style={styles.lessonDescription}>{lesson1.lessonName}</Text>
</View>
)
