Skip to content

Instantly share code, notes, and snippets.

@mateuszsokola
Last active October 21, 2017 22:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mateuszsokola/c5d013d8acce41a0dfd004276c9210f2 to your computer and use it in GitHub Desktop.
Save mateuszsokola/c5d013d8acce41a0dfd004276c9210f2 to your computer and use it in GitHub Desktop.
// without immutable
initialState.numbers = numbers.filter((num:number):boolean => {
return num % 2 === 0;
})
console.log('after update:', initialState);
// after update: { numbers: [ 2, 4, 6 ] }
// 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