Application Android et IOS pour l'amicale des élèves
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

PureFlatList.js 876B

123456789101112131415161718192021222324252627282930313233
  1. import * as React from 'react';
  2. import {FlatList} from "react-native";
  3. type Props = {
  4. data: Array<Object>,
  5. keyExtractor: Function,
  6. renderItem: Function,
  7. updateData: number,
  8. }
  9. /**
  10. * FlatList implementing PureComponent for increased performance.
  11. *
  12. * This is a pure component, meaning it will only update if a shallow comparison of state and props is different.
  13. * To force the component to update, change the value of updateData.
  14. */
  15. export default class PureFlatList extends React.PureComponent<Props> {
  16. static defaultProps = {
  17. updateData: null,
  18. };
  19. render() {
  20. return (
  21. <FlatList
  22. data={this.props.data}
  23. keyExtractor={this.props.keyExtractor}
  24. style={{minHeight: 300, width: '100%'}}
  25. renderItem={this.props.renderItem}
  26. />
  27. );
  28. }
  29. }