Estoy obteniendo una matriz de dos objetos. hay una matriz "título" y "iqtiboslar" dentro de los objetos. y muéstrelo en SectionList pero está dando un error: "no se pueden leer las propiedades de undefined (leyendo 'longitud')".
Aquí está mi código. Cualquier idea será muy apreciada.
const Item = ({iqtiboslar}) => ( <View> <Text>{iqtiboslar}</Text> </View> ); const HomeScreen = ({navigation}) => { const [quote, setQuote] = useState(); useEffect(() => { fetchQuotes(); return () => { setQuote(); }; }, []); const fetchQuotes = async () => { try { const quoteCollection = await firestore().collection('iqtiboslar').get(); // get(:field) to get specific doc quoteCollection._docs.map(doc => setQuote(doc.data().items)); // quoteCollection._docs.map(doc => console.log(doc)); } catch (error) { console.log(error); } }; return ( <View style={styles.container}> {quote ? ( <SectionList sections={quote} keyExtractor={(item, index) => item + index} renderItem={({item}) => <Item title={item.title} />} renderSectionHeader={({section}) => <Text>{section.title}</Text>} /> ) : ( <ActivityIndicator /> )} </View> ); }; export default HomeScreen; const styles = StyleSheet.create({ container: { flex: 1, justifyContent: 'center', alignItems: 'center', }, text: { color: 'red', }, });Prueba este código
<SectionList sections={quote} keyExtractor={(item, index) => item + index} renderItem={({item}) => <Text>{item}</Text>} renderSectionHeader={({section: {title}}) => ( <Text style={styles.text}>{title}</Text> )}