New to react native. I have a simple component that takes in a list of ingredients and returns the items in a flatList of text. For some reason I can’t get the data to render. Am I doing something wrong?
My ingredients looks like this:
const ingredients = [chicken, butter, oil]
const DisplayRec = ({ ingredients }) => {
return (
<View style={styles.container}>
<Text>Your Recipes</Text>
<FlatList
//keyExtractor={(recName) => recName}
data={ingredients}
renderItem={({ recName }) => (
<Text>{recName}</Text>
)}
/>
</View>
);
};
3
Answers
You are using it in incorrect manner
please try
also please go throught the documentation of FlatList
https://reactnative.dev/docs/flatlist#required-renderitem
you need to use return in render item
Hope it’s working fine for you
For live editing expo link