Dynamically changing number of columns in React Native Flat List

Pass a changing value to the FlatList itself. It has nothing to do with the keyExtractor or the key attrbibute in renderItem methods:

<FlatList key={changingValue} .. /> 

should solve it.


In Hooks

const [numCols, setColumnNo] = useState(0);

<FlatList
key={numCols}
numColumns={numCols}
...
/>

I did it using key

    numColumns = {this.state.columnCount}
    key={this.state.columnCount}

From the documentation, looks like you should do something like this

key={(this.state.horizontal ? 'h' : 'v')}