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

525
Vistas
React Native - Erro Flatlist number of columns

I'm using the flatlist in two different components to render different columns. One component will render three columns and the other just one column. However, when I change the state of my application, it returns the following error:

"Changing numColumns on the fly is not supported. Changed the key prop on FlatList when changing the number of columns to force a fresh render of the component."

    renderGrade() {
        return (
            <View style={telaStyle.container}>
                <FlatList
                    style={{ marginBottom: 10 }}
                    data={this.props.restauranteReducer.lstFamilias}
                    renderItem={({ item }) => (
                        <Familia
                            onPressFamilia={async () => {
                                if (this.listItemDisabled === false) {
                                    this.listItemDisabled = true;
                                    await this.onPressFamilia(item);
                                    this.listItemDisabled = false;
                                }
                            }}
                            item={item}
                        />
                    )}
                    keyExtractor={(item) => `${item.codigo.toString()}`}
                    numColumns={3}
                    refreshing={this.state.loading}
                    onRefresh={this.handlerRefresh}
                />
            </View>
        );
    }

    renderLista() {
        return (
            <View style={telaStyle.containerLista}>
                <FlatList
                    style={{ marginBottom: 10 }}
                    data={this.props.restauranteReducer.lstFamilias}
                    renderItem={({ item }) => (
                        <FamiliaLista
                            onPressFamilia={async () => {
                                if (this.listItemDisabled === false) {
                                    this.listItemDisabled = true;
                                    await this.onPressFamilia(item);
                                    this.listItemDisabled = false;
                                }
                            }}
                            item={item}
                        />
                    )}
                    keyExtractor={(item) => `${item.codigo.toString()}`}
                    numColumns={1}
                    refreshing={this.state.loading}
                    onRefresh={this.handlerRefresh}
                />
            </View>
        );
    }

    render() {
        return (
            this.props.sessionUsuario.visualizaGrade ?
                this.renderGrade()
                :
                this.renderLista()

        );
    }

If I leave both FlatList with the same number of columns, work, but I need it to be a FlatList with one column and another with three.

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

0

I ended up figuring out what my problem was, both flatlist were on the same tree level as the components. To solve it I included the renderList flatlist inside a simple View and it worked.

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