DekGenius.com
Home
(current)
Dictionary
BOOKS
LYRICS
CHORD
SCRIPT & CODE EXAMPLE
Karaoke language
Search
Go
SCRIPT & CODE EXAMPLE
CODE EXAMPLE FOR JAVASCRIPT
react useState update object in array of objects
this
.
setState
(
{
items
:
this
.
state
.
items
.
map
(
x
=>
x
.
id
===
someId
?
{
...
x
,
attr
:
'val'
}
:
x
)
}
)
;
Source by stackoverflow.com #
PREVIOUS
NEXT
Tagged:
#react
#useState
#update
#object
#array
#objects
ADD COMMENT
Topic
COMMENT
Name
7+6 =
Submit