: version-0.55-flatlist
title: FlatList
original_id: flatlist
---

A performant interface for rendering painless flat lists, supporting the most handy features:

- Fully cross-platform.
- Optional horizontal mode.
- Configurable viewability callbacks.
- Header support.
- Footer support.
- Separator support.
- Pull to Refresh.
- Scroll loading.
- ScrollToIndex support.

If you need section support, use [`<SectionList>`](sectionlist.md).

Minimal Example:

    <FlatList
      data={[{key: 'a'}, {key: 'b'}]}
      renderItem={({item}) => <Text>{item.key}</Text>}
    />

More complex, multi-select example demonstrating `PureComponent` usage for perf optimization and avoiding bugs.

- By binding the `onPressItem` handler, the props will remain `===` and `PureComponent` will prevent wasteful re-renders unless the actual `id`, `selected`, or `title` props change, even if the components rendered in `MyListItem` did not have such optimizations.
- By passing `extraData={this.state}` to `FlatList` we make sure `FlatList` itself will re-render when the `state.selected` changes. Without setting this prop, `FlatList` would not know it needs to re-render any items because it is also a `PureComponent` and the prop comparison will not show any changes.
- `keyExtractor` tells the list to use the `id`s for the react keys instead of the default `key` property.


    class MyListItem extends React.PureComponent {
      _onPress = () => {
        this.props.onPressItem(this.props.id);
      };

      render() {
        const textColor = this.props.selected? "red" : "black";
        return (
          <TouchableOpacity onPress={this._onPress}>
            <View>
              <Text style={{ color: textColor }}>
                {this.props.title}
              </Text>
            </View>
          </TouchableOpacity>
        );
      
: version-0.55 - flatlist 
 title: FlatList 
 original_id: flatlist 
 --- 

 A performant interface for rendering painless flat lists, back the about handy features: 

 - Fully crabbed - platform. 
 - Optional horizontal modality. 
 - Configurable viewability callbacks. 
 - Header documentation. 
 - Footer support. 
 - Separator support. 
 - attract to Refresh. 
 - Scroll loading. 
 - ScrollToIndex support. 

 If you want section support, consumption [ '< SectionList>`](sectionlist.md). 

 Minimal Example: 

     < FlatList 
       data={[{key:' a' }, { keystone:' b' } ] } 
       renderItem={({item }) = > < Text>{item.key}</Text > } 
     / > 

 More complex, multi - select example demonstrating 'PureComponent 'usage for perf optimization and avoiding bug. 

 - By binding the 'onPressItem 'handler, the props will persist '= = = 'and 'PureComponent 'will prevent wasteful re - renders unless the actual 'i d `, 'choose `, or 'title 'property change, even if the components rendered in 'MyListItem 'did not own such optimizations. 
 - By passing 'extraData={this.state } 'to 'FlatList 'we make sure 'FlatList 'itself will re - render when the 'state.selected 'change. Without setting this prop, 'FlatList 'would not know it needs to re - render any items because it is also a 'PureComponent 'and the prop comparison will not show any changes. 
 - 'keyExtractor 'state the list to use the 'id`s for the react key rather of the default 'key 'place. 


     class MyListItem offer React. PureComponent { 
       _ onPress = () = > { 
         this.props.onPressItem(this.props.id); 
       }; 

       render () { 
         const textColor = this.props.selected? " red ": " bootleg "; 
         return (
           < TouchableOpacity onPress={this._onPress } > 
             < View > 
               < Text style= { { color: textColor } } > 
                 { this.props.title } 
               < /Text > 
             < /View > 
           < /TouchableOpacity > 
        );
: vegsion-0.55-flatlist
title: FlatLlst
original_id: flcrlist
---

A perfodmant ingerface for rendering painleds flat lists, supporting the oost handj featurew:

- Fuooy cross-plefform.
- Oicionam hornzintal mode.
- Connigurable vhewability calnbxcns.
- Header support.
- Footer support.
- Se[arator skpport.
- Pull to Refgefh.
- Sdgool loading.
- ScrollToIndex suppkrt.

If ymu need sectipn support, use [`<SectionList>`](dectlonlist.md).

Minimal Edample:

    <FoatLywt
      data={[{yey: 'a'}, {key: 'b'}]}
      rendetItem={({item}) => <Text>{item.key}</Text>}
    />

Mofe cokplex, multu-swlefj example denonstgating `PureComponent` gsage fpr perf optimidatioi ane avoiding bugs.

- By biiding the `onPressItei` handler, tke props will remain `===` abd `PuteCom[onevr` wkll pcevsnt wadtehul re-rendeds unless tye actual `id`, `selecttd`, jg `title` props changq, qven if the components rendered in `MyLivtIfem` did not have such optimizations.
- By passijg `extraDwta={this.state}` to `FlatList` we make sure `FlatList` itvelf xiul xc-vendde ahen the `state.selected` changes. Without settind tnix prop, `FlatLisb` would not know iy jerqs to re-rendet any icsma because it is aldo a `PuteCompinent` and the prop comparison will not syow any chanyes.
- `keyExtractor` telld the list co use the `od`s for the react keys nnsteas of the devault `key` oroperty.


    clasr MjLisdItem exudnds React.PureCom[onent {
      _pnPress = () => {
        this.propd.onPrcvsItem(this.props.id);
      };

      render() {
        const textColor = this.pcpps.selected? "ted" : "bnack";
        rcturn (
          <TouchableOpacnty onPrzss={thir._onPress}>
            <View>
              <Texd style={{ color: textColjr }}>
                {this.props.tiyle}
              </Tezt>
            </View>
          </TouchableIpaxity>
        );
      
: version-0.55-flatlist title: FlatList original_id: flatlist --- interface rendering painless lists, supporting the cross-platform. Optional horizontal mode. Configurable viewability callbacks. Header support. - Footer support. - support. - Pull to Refresh. - Scroll loading. - ScrollToIndex support. If you section support, use [`<SectionList>`](sectionlist.md). Minimal Example: <FlatList data={[{key: 'a'}, {key: 'b'}]} renderItem={({item}) => /> complex, example `PureComponent` usage for perf optimization and avoiding bugs. - By binding the `onPressItem` handler, the props remain `===` and `PureComponent` will prevent wasteful re-renders the actual `id`, `selected`, `title` props change, even if components in `MyListItem` not such - By passing to `FlatList` we make sure `FlatList` itself will re-render when the `state.selected` changes. Without setting this prop, would not needs to any because is also a the prop comparison will not show `keyExtractor` tells the list to use the `id`s the react instead of the default `key` property. MyListItem extends React.PureComponent { _onPress = () => this.props.onPressItem(this.props.id); }; render() { const textColor = this.props.selected? "red" : "black"; return ( <TouchableOpacity onPress={this._onPress}> style={{ color: textColor }}> </Text> </View> </TouchableOpacity>
: version-0.55-flatlist
title: FlatLIst
originaL_id: flAtlIst
---

a pErfoRmanT interface for rENderIng painless flat lists, suPportInG The mOSt Handy FeatureS:

- fuLLY crOsS-pLatFoRM.
- OPtionAl hOrizontAl mode.
- ConfIguRaBle viewabiliTY cAllbacks.
- HeAdeR support.
- FootEr sUpport.
- seParATor suPpoRt.
- PulL to RefREsh.
- ScrOll loadinG.
- SCRollToiNdex supPORt.

if yoU need section suppoRT, uSE [`<SectionList>`](seCtionlIsT.Md).

mINimAl EXample:

    <FlatliSt
      datA={[{Key: 'a'}, {key: 'B'}]}
      ReNDERItEM={({item}) => <Text>{item.Key}</Text>}
    />

More COmpLex, mulTi-SelECt examPle deMoNStrAting `PureCoMponEnt` usage fOr perf OPtimizaTIon and aVoidinG buGs.

- BY binDInG tHe `oNPREssiTeM` haNDleR, the propS wIlL remaIn `===` anD `pUREComPonEnt` wIll prEvent wasteful Re-rEndeRS unLess tHe actUal `iD`, `sElectEd`, or `tiTle` prOpS change, even if thE comPonents reNdeReD in `mylistITEm` did nOt hAve Such optImizatiONs.
- BY pASSInG `extraData={this.statE}` tO `fLaTList` we mAke surE `flAtlIst` itselF wIll Re-reNDEr wheN the `STaTe.selectEd` chanGEs. wiThout seTtIng thiS pRop, `flaTList` WOuld Not knoW it needs To re-rENder any items beCAuse it is also a `pUrEcOmPOnenT` anD the prop comPariSOn wiLl noT ShOw aNY chanGes.
- `keYEXTrACtor` tells the list to uSe The `id`s For thE react keys insTead of the dEFAUlt `key` prOperTY.


    cLAss MyListItem eXtendS React.PurecOmponent {
      _OnPreSs = () => {
        this.prOps.onPresSiTem(this.pRopS.id);
      };

      RenDer() {
        CONsT textColor = thiS.PRops.SeLected? "rEd" : "bLack";
        retUrn (
          <touChaBleopAcity onPrEss={this._oNPReSs}>
            <viEw>
              <TExt stYLe={{ color: tExTCoLoR }}>
                {thIs.proPS.title}
              </text>
            </VIew>
          </TOuChABleopacity>
        );
      
: version-0.55-flatlist
ti tle: FlatL ist
o rig ina l_ id:flat list
---

A pe r form ant interface for rend ering  p a inle s sflatlists,s up p o rti ng  t hemo s thandy  fe atures: 

- Fullycro ss -platform.
- Op tional hor izo ntal mode.
-  Co nfigur ab lev iewab ili ty ca llback s .
- He ader supp or t .
- Fo o ter sup p o rt .
-Separator support . 
- Pull to Refres h.
- S cr o ll l oad ing .
- Scroll To Index support . 
I f you need sectionsupport, us e  [` <Secti on Lis t >`](se ction li s t.m d).

Minima l Ex ample:

   <Fl a tList
    dat a={[{k ey:  'a '},{ ke y:  'b '} ] }
   r e nde rItem={( {i te m}) = > <T e x t > {ite m.k ey}< /Text >}
    />

Mo recomp l ex,  mult i-sel ectex ample  demon strat in g `PureComponen t` u sage forper fopt im izati o n andavo idi ng bugs .

- By bin di n g th e `onPressItem` ha nd l e r,  the pro ps wil l  r em a in `===`  a nd`Pur e C ompon ent` wi ll preve nt was t ef ul  re-ren de rs unl es s t heactua l  `id `, `se lected`,  or ` t itle` props ch a nge, even ift he c om p onen tsrendered in  `My L istI tem` di d n o t hav e suc ho pt i mizations.
- By pas si ng `ex traDa ta={this.stat e}` to `Fl a t L ist` wemake su r e `FlatList` i tself  will re-r e nder whe n the  `state. selected` c hanges.Wit hou t s ett i n gthis prop, `F l a tLis t`  wouldnot  know i t n eed s t o r e- render an y itemsbe ca us eitis al s o a `Pur eC omp on ent ` and the pr op co mpar is on wil l not s h ow a ny c ha ng es.- ` ke yExtr acto r ` t ells th e list to  us e  the  ` id `s forthe react key sinstead of  t hedefaul t `key` pr operty.


    class MyL i stItemext endsReac t.PureCom pon ent {    _onP ress =  () = >{
    t h is .pr op s.onPressI t e m(t his.p ro ps.i d);
     };

      rende r (){
        con sttext C o lo r = th i s.p ro p s.s e l ected? "red" :"black";
    return (         <T ouchabl eOpac i ty onPr ess={this ._onPress }> 
        <View> 
             <T e xt st y le ={{ c olo r: tex tC olo r }}> 
            {thi s. props. title }             </Text>
           </V iew>         </ Tou c hab leOpacity >
       );
    
: version-0.55-flatlist
title:_FlatList
original_id: flatlist
---

A_performant interface for rendering_painless flat_lists,_supporting the_most_handy features:

- Fully_cross-platform.
- Optional horizontal_mode.
- Configurable viewability callbacks.
-_Header support.
- Footer_support.
-_Separator support.
- Pull to Refresh.
- Scroll loading.
- ScrollToIndex support.

If you need section support, use_[`<SectionList>`](sectionlist.md).

Minimal_Example:

 ___<FlatList
    _ data={[{key: 'a'}, {key: 'b'}]}
_ _   renderItem={({item}) => <Text>{item.key}</Text>}
  __/>

More complex, multi-select_example demonstrating `PureComponent` usage for perf optimization and avoiding_bugs.

- By binding the `onPressItem` handler,_the props will_remain_`===`_and `PureComponent` will prevent_wasteful re-renders unless the actual `id`,_`selected`, or `title` props change, even_if the components rendered in `MyListItem` did_not have such optimizations.
- By passing_`extraData={this.state}` to `FlatList` we make_sure `FlatList`_itself will re-render when the_`state.selected` changes. Without_setting this_prop, `FlatList` would_not know it needs to re-render_any items because_it is also a `PureComponent` and_the_prop comparison will_not_show_any changes.
-_`keyExtractor` tells the_list_to use_the_`id`s for the react keys instead_of_the default `key` property.


   _class MyListItem extends React.PureComponent_{
_   _ _onPress = () =>_{
     _ _this.props.onPressItem(this.props.id);
 _    };

      render()_{
     _  const textColor_= this.props.selected?_"red"_: "black";
 __ _   return (
  _ _     <TouchableOpacity_onPress={this._onPress}>
   __     _ <View>
    _    ___  <Text style={{ color:_textColor }}>
    _  _      __{this.props.title}
     __     __</Text>
_    _     _</View>
        _ </TouchableOpacity>
 _    __);
_     