score:0
you can map over familymembers array and update when you find user.id and update that avatar.
const users = current(state.data.familymembers)
const familymembers = users.map(user => {
if(user.id === id) {
return { ...user, avatar };
} else {
return user;
}
}
const userindex = users.findindex((user) => user.id === id)
return {
...state,
data: {
...state.data,
familymembers: familymembers,
},
};
Source: stackoverflow.com
Related Query
- updating array object in redux phrasing error?
- Redux store is not updating when modifying element propriety of an array object
- updating a single object key value inside array of objects react redux state
- Redux not updating state correctly -- state stays as empty array despite adding an object in the line prior
- Updating an object within array in react redux reducer getting map() is not a function
- Error React Redux Toolkit: Why I can't change the key value the array object using .findIndex
- Redux - ES6 Updating Object Element in Array
- Object is not extensible error when creating new attribute for array of objects
- Updating the array object in React state using immutability helper
- Update array object in React Redux reducer
- ReactJS updating a single object inside a state array
- how to save array object data in redux store
- Get axios Response object when error occurred with Redux Saga
- React not updating state with setState with Array of object
- Updating property of object within stored array - React Native
- React.js state items array not updating properly even not showing any error
- Mapping Object Array Data in Redux
- ReactJS: Updating array inside object state doesn't trigger re-render
- Updating the field of the nested object not re-rendering the views (UI) in React Redux
- Redux - Find object in state array by its key and update its another key
- ES6 map is throwing error on array of object
- Updating Redux store to remove something from array doesn't rerender
- Getting referrence error while creating new array of object from existing array of objects?
- updating array in object properties
- React redux - issues adding multiple items to an array in state tree object
- updating multiple items in redux array
- How add item in nested array of object in redux reducer
- updating object inside array inside object using prevState and the useState hook
- Update a redux array of object but not re-render the component
- Object is possibly null error (typescript) when trying to display the value of an array which is stored in localstorage
More Query from same tag
- Connecting Redux devtools and Thunk middleware to store
- How to enforce Typescript to check that all keys in an object are present in array, where said keys are used as a value?
- Can't load assets from public folder in development mode in webpack
- How to convert CSS with properties to MaterialUI Styles in ReactJS
- React Js Child Cannot receive parents props
- Unable to execute if statement
- React-Router-Dom 6+ throwing Attempted import error: 'withRouter' is not exported from 'react-router-dom'
- React - Each child in a list should have a unique "key" prop
- Unable to access data from a form submission in a POST request
- Dinamic data from mui-datatable
- caching app shell in a React PWA with Server-Side rendering
- Is it possible to add a key attribute after a React component is instantiated?
- Custom function in function chain - To get Length of Array
- React Router <redirect> not working
- material ui slider component onChange event not working with Fromik handleChange event
- How to solve the "update was not wrapped in act()" warning in testing-library-react?
- Jest, How to mock a function inside an object?
- Fetch JSON data with dashes or hyphens in React
- "Semi-controlled" component in react
- Component is somehow rendering despite conditional statement
- How to use renderArrowPrev in React Responsive Carousel to implement next and previous functionality?
- Append component dynamically into a map function
- How to return a tree of react tags from a Map() object in React?
- Excluding modules from Webpack DLL build
- Use a state variable inside a method in React
- React Native build failed: 'React/RCTBridge.h' file not found
- how to conditionally add props on a react component?
- Express server serves my static files but does not handle requests to my API. What is happening?
- React Hook useEffect has a missing dependency: 'ans.group._id'. Either include it or remove the dependency array, why?
- To add additional characters to a string obtained from api response