Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

524
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!