Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

169
Vistas
React native SectionList is not showing data from firebase

I am fetching an array of two objects. there are "title" and "iqtiboslar" array inside objects. and show it in SectionList but it is giving an error: "can not read properties of undefined(reading 'length')". enter image description hereHere is my code. Any ideas will be highly appreciated

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',
  },
});

data coming from firebase, console.log(quote);

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Try this code

<SectionList
          sections={quote}
          keyExtractor={(item, index) => item + index}
          renderItem={({item}) => <Text>{item}</Text>}
          renderSectionHeader={({section: {title}}) => (
            <Text style={styles.text}>{title}</Text>
          )}
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda