I want to replace the object with the same ID in an array. I have used .unionBy using Lodash. The problem is the the new object appears at the the first instead of the same index.
Here is my code. Hope you can help me. Thanks!
state.allStudents is the array. And the students is the new object to replace that existing object in the array with same _id
state.allStudents = _.unionBy([students], state.allStudents, '_id');