Last active
October 21, 2017 22:49
-
-
Save mateuszsokola/c5d013d8acce41a0dfd004276c9210f2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// without immutable | |
initialState.numbers = numbers.filter((num:number):boolean => { | |
return num % 2 === 0; | |
}) | |
console.log('after update:', initialState); | |
// after update: { numbers: [ 2, 4, 6 ] } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// with immutable | |
initialState.numbers = numbers.filter((num:number):boolean => { | |
return num % 2 === 0; | |
}) | |
// throws error: Cannot set on an immutable record. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment