javascript - React Native Endless Loop -


i using react-native iostabbar following example:

  render: function() {      return (        <tabbarios          tintcolor="white"          bartintcolor="#d7df01">          <tabbarios.item            title="all"            icon={require('./x.png')}            selected={this.state.selectedtab === 'x'}            onpress={() => {              this.setstate({                selectedtab: 'x',              });            }}>            {this._rendercontent(this.state.selectedtab)}          </tabbarios.item>          <tabbarios.item            icon={require('./y.png')}            title="incoming"            selected={this.state.selectedtab === 'y'}            onpress={() => {              this.setstate({                selectedtab: 'y'              });            }}>            {this._rendercontent(this.state.selectedtab)}          </tabbarios.item>          <tabbarios.item            icon={require('./z.png')}            title="outgoing"            selected={this.state.selectedtab === 'z'}            onpress={() => {              this.setstate({                selectedtab: 'z'              });            }}>             {this._rendercontent(this.state.selectedtab)}          </tabbarios.item>        </tabbarios>      );    }, 

within _rendercontent method executing sqllite select ends in endless loop..is normal tabbar ? can ?

don't put sqllite call within render. use lifecycle methods, because every time component renders will:

  • make call
  • update state
  • trigger render

and on.

why don't try put call in componentdidmount method, assign result state setstate({ tab1content: sqliteresult }) , call _rendercontent tab1content state


Comments

Popular posts from this blog

sequelize.js - Sequelize group by with association includes id -

android - Robolectric "INTERNET permission is required" -

java - Android raising EPERM (Operation not permitted) when attempting to send UDP packet after network connection -