Skip to content

How you support orientation changes on FlatList without changing columns on the fly? #15944

@ferrannp

Description

@ferrannp

I remember using FlatList when it didn't have this check:

invariant(
   nextProps.numColumns === this.props.numColumns,
   'Changing numColumns on the fly is not supported. Change the key prop on FlatList when ' +
   'changing the number of columns to force a fresh render of the component.',
 );

So basically I wrapped the FlatList in a View with onLayout prop, and when the width of screen changes (from portrait <-> layout) I would change the number of columns (and some other calculations). This is not allowed now, so what it forces me to do is changing the key prop of the FlatList... This renders a completely new list, losing the scroll position and with a big delay even in production.

Any workarounds, thoughts ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Ran CommandsOne of our bots successfully processed a command.Resolution: LockedThis issue was locked by the bot.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions