AJC
AJC

Reputation: 43

How to update redux state without creating new array

export const initialState = {
   data: [1,2,3]
}

after success api request i am updating data state

 data: state.data.concat(...action.data.data) 

All the flat list items are getting re-render as concat is returning new array.(onReachEnd i am calling api for next page. and that data needs to added in redux state without updating whole array )

Upvotes: 1

Views: 53

Answers (1)

programmingTantrik
programmingTantrik

Reputation: 180

You can just destructure both

data : [...state.data, ...action.data.data]

Upvotes: 1

Related Questions