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

329
Vistas
Accordion inside a Flatlist React native

I have an accordion inside a flatlist.

Here is the code i have :

const OptionList = (groupOption) => {
   return (
    <FlatList
      data={groupOption.options}
      keyExtractor={(result) => result.id.toString()}
       renderItem={({ item, index }) => {
         const clickedRadio = () => {
         const selectedOption = { [item.question]: { ...item } };
           setAnswers({ ...answers, ...selectedOption });
         };
         const status = isOptionSelected(item) ? true : false;

         return (
          <View key={index}>
            <Radio
              initialValue={status}
              label={item.description}
              onChange={() => clickedRadio()}
              color="error"
             />
          </View>
         );
        }}
      />
    );
  };

  return (
    <View style={styles.container}>
      <Text style={{ fontWeight: "bold", fontSize: 16, color:"#6B24AA" }}>
       {t("Choose an option/Scroll for more questions")}
      </Text>
  
      <FlatList
        data={questions}
        listKey={(item) => item.id.toString()}
        keyExtractor={(result) => result.id.toString()}
        renderItem={({ item, index }) => {
          const data = [
          {
            title: item.description,
            content: (<><OptionList options= 
              {item?.question_options}></OptionList></>)
          }
         ];
       const status = isOptionSelected(item) ? true : false;
       return (
        <View style={styles.groupOptions} key={index}>
          <Accordion style={styles.accordion} 
           headerStyle= 
          {styles.headerStyle} contentStyle={styles.contentStyle} 
          dataArray={data} 
          icon={status ? <Icon name="circle" 
          family="Entypo" size={20} style={{marginLeft: -6, 
          color: "#6B24AA"}}/> 
          : 
           <Icon name="done" 
          family="MaterialIcons" size={20} 
          style={{marginLeft: -6}}/>} 
          expandedIcon={<Icon name="circle" 
          family="Entypo"/>} 
          opened={1}/>
        </View>
      );
    }}
  />
</View>

);

The accordion content its anther flatlist component. It shows this error every time i click the accordion.

It shows this error :

VirtualizedList: Encountered an error while measuring a list's offset from its containing VirtualizedList.
at node_modules/react-native/Libraries/Lists/VirtualizedList.js:1411:10 in _scrollRef.measureLayout$argument_2

How can i fix this error? Is it the problem the other flatlist at the content of accordion

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

0

Please replace the OptionList component with the given below code.

OptionList

const OptionList = (groupOption) => {
return (
    groupOption.map((item,index) => {
        const clickedRadio = () => {
        const selectedOption = { [item.question]: { ...item } };
              setAnswers({ ...answers, ...selectedOption });
        };
        const status = isOptionSelected(item) ? true : false;
        return (
        <View key={index}>
         <Radio
           initialValue={status}
           label={item.description}
           onChange={clickedRadio}
           color="error"
          />
       </View>
        )
    })
 );
};

please check and let me know , cheers !

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