Skip to content

Commit 69ee704

Browse files
authored
Updating Arrays in State
1 parent 845a8c6 commit 69ee704

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,3 +209,14 @@ On this page you learned:
209209

210210
<br>
211211

212+
213+
### Updating Arrays in State
214+
215+
- You can put arrays into state, but you can’t change them.
216+
- Instead of mutating an array, create a _new_ version of it, and update the state to it.
217+
- You can use the `[...arr, newItem]` array spread syntax to create arrays with new items.
218+
- You can use `filter()` and `map()` to create new arrays with filtered or transformed items.
219+
- You can use Immer to keep your code concise.
220+
221+
*link: https://react.dev/learn/updating-arrays-in-state*
222+

0 commit comments

Comments
 (0)