Updating arrays in state Flashcards
1
Q
What can you put into state?
A
Arrays
2
Q
What should you do instead of mutating an array?
A
Create a new version of it and update the state to it
3
Q
Which syntax is used to create arrays with new items?
A
[…arr, newItem]
4
Q
Which methods can be used to create new arrays with filtered or transformed items?
A
filter() and map()
5
Q
What library can you use to keep your code concise?
A
Immer
6
Q
Fill in the blank: You can use _______ to create arrays with new items.
A
[…arr, newItem]
7
Q
True or False: You can directly mutate an array in state.
A
False