Nativebase: List is not re-rendering when children change on iOS

Created on 5 Apr 2017  路  4Comments  路  Source: GeekyAnts/NativeBase

Just getting my app to run on iOS and found another bug.
Using "native-base": "^2.0.13", and "react": "15.4.2", "react-native": "0.42.0",

<List
      dataArray={cars}
      renderRow={(car,i)=>
                            <Car car={car} key={i} onSelect={this.onSelect} isEdit={isEdit}/>}
   />

Now I change isEdit from false to true (isEdit is from state) and rows are not rerendered.
Even updating keys of "Car" does not trigger re-render of list.
This is however working on android.

Most helpful comment

Temporary fix:

<List
     key={iKey}
     dataArray={cars}
      renderRow={(car,i)=>
                     <Car car={car} key={i} onSelect={this.onSelect} isEdit={isEdit}/>}
 />

Use another state variable eg iKey and increase it everytime you want to perform update on rows of list.

All 4 comments

Temporary fix:

<List
     key={iKey}
     dataArray={cars}
      renderRow={(car,i)=>
                     <Car car={car} key={i} onSelect={this.onSelect} isEdit={isEdit}/>}
 />

Use another state variable eg iKey and increase it everytime you want to perform update on rows of list.

This is because the default rowHasChanged method is stupid because it does not perform a deep comparison. We need the ability to pass in a custom rowHasChanged function.

Fixed with v2.1.3

@obykoo thanks it worked for me.

Was this page helpful?
0 / 5 - 0 ratings