React native redux and ListView -


i have seen @ least 1 similar question.

however interested in pattern redux usage in react native application having listview. should reducers create new listview.datasource every time? cause performance problems etc., asked question pointed out? or should take deviation , call setstate({datasource : new listview.datasource()}) componentwillreceiveprops() of component has listview?

i went componentwillrecieveprops route. given clonewithrows needs new object each time updated (depending on how use rowhaschanged), 1 needs pass new set of data it. luckily redux reducers, kind of pattern expected anyways in terms of data return.

here's how did in app of mine:

componentwillreceiveprops(newprops) {   let days = newprops.days;   if (newprops.viewingdayuuid !== this.props.viewingdayuuid) {     days = days.map((day) => {       if (day.uuid === newprops.viewingdayuuid || day.uuid === this.props.viewingdayuuid) {         return object.assign({}, day);       } else {         return day;       }     });   }   this.setstate({     datasource: this.state.datasource.clonewithrows(days)   }); } 

the if block can ignore, that's me deciding make new day object if current selected (highlight state) nav item in list view needs change. instead of returning whole new objects each time


Comments

Popular posts from this blog

java - Static nested class instance -

c# - Bluetooth LE CanUpdate Characteristic property -

JavaScript - Replace variable from string in all occurrences -