diff --git a/components/PureFlatList.js b/components/PureFlatList.js index fd87c69..8389d5e 100644 --- a/components/PureFlatList.js +++ b/components/PureFlatList.js @@ -1,9 +1,23 @@ import * as React from 'react'; import {FlatList} from "react-native"; +type Props = { + data: Array, + keyExtractor: Function, + renderItem: Function, + updateData: number, +} +/** + * This is a pure component, meaning it will only update if a shallow comparison of state and props is different. + * To force the component to update, change the value of updateData. + */ export default class PureFlatList extends React.PureComponent{ + static defaultProps = { + updateData: null, + }; + render() { return ( { data={this.state.currentlyDisplayedData} keyExtractor={this.keyExtractor} renderItem={this.renderItem} + updateData={this.state.currentSortMode} /> );