Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

523
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda