You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When i was trying to make a selectable list i bring the objects of DB and added a new attribute called 'isSelected', however, when i call the "find()" in my update method in controller he brings to me the object with the "isSelected" even me not performing other action on the database, in my knowledge of javascript the rest/spred operator doesn't preserve the reference to the original object but make a copy of him.
Does it have an explanation or error in my logic ?
Modifying the objects:
let listUsers = await userController.getAll();
listUsers = listUsers.map(item => ({
...item,
isSelected: false,
}));
//works well
setUsers(listUsers); //state "users" of my component
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
When i was trying to make a selectable list i bring the objects of DB and added a new attribute called 'isSelected', however, when i call the "find()" in my update method in controller he brings to me the object with the "isSelected" even me not performing other action on the database, in my knowledge of javascript the rest/spred operator doesn't preserve the reference to the original object but make a copy of him.
Does it have an explanation or error in my logic ?
Modifying the objects:
The UserController:
Beta Was this translation helpful? Give feedback.
All reactions