React Redux: Difference between revisions

From bibbleWiki
Jump to navigation Jump to search
No edit summary
Line 14: Line 14:
* No side effects
* No side effects
* Also yields same result
* Also yields same result
=Immutability=
ES6 allows us to copy objects using Object.assign e.g.
<syntaxhighlight lang="javascript">
var state = {color:'red', name: 'Adam', point:5}
var state2 = Object.assign({}, state, {point:50})
</syntaxhighlight>

Revision as of 04:06, 23 May 2020

Unidirectional

Data only flows one direction

Pure Functions

  • Like static is c#/c++ only using inputs to produce outputs
 function multiply(a, b)
 {
   return a * b;
 }
  • No side effects
  • Also yields same result

Immutability

ES6 allows us to copy objects using Object.assign e.g.

var state = {color:'red', name: 'Adam', point:5}
var state2 = Object.assign({}, state, {point:50})