reactjs - How to add new data to state without data getting refreshed in react -


i'm rendering data api, i'm adding load more option more data. while new data rendered, component getting refreshed, state changes.

how can solve ?

this code :

export  const newdatareducer = (state= initialstate , action = null) => {     switch(action.type) {     case types.get_new_data:         let mydata;         mydata = _.unionby(state.data, action.payload.data, "id");         return object.assign({}, state, {isloading:false, data:mydata, notification: "success" });     } } 

my component :

_.map(mydata, (newdata, index) => {     return (         newdata.id;     ); }); 

thank you

you can add logic shouldcomponentupdate lifecycle method prevent unwanted rendering.


Comments

Popular posts from this blog

php - Permission denied. Laravel linux server -

google bigquery - Delta between query execution time and Java query call to finish -

python - Pandas two dataframes multiplication? -