Re:Pros and Cons of using immutability with React.js
by k__ on Friday August 14, 2015 @11:56AM
(#10060821)
This week I learned to love the spread operator.
[ Parent
| on HN ]
Re:Pros and Cons of using immutability with React.js
by smrq on Friday August 14, 2015 @12:23PM
(#10061000)
That's really cool. Worth noting that it's an ES7 proposal rather than part of ES6, so you get it with Babel but not native ES6, or e.g. TypeScript.
Re:Pros and Cons of using immutability with React.js
by andrewstuart2 on Friday August 14, 2015 @11:59AM
(#10060839)
Whoa, that works on objects/properties? I hadn't seen that before. That's nice.
Re:Pros and Cons of using immutability with React.js
by lowboy on Friday August 14, 2015 @12:24PM
(#10061013)
Just keep in mind that object spread operators are a TC39 stage 1 proposal at this point.
Re:Pros and Cons of using immutability with React.js
by k__ on Friday August 14, 2015 @12:03PM
(#10060878)
Yes, here some simple examples:
(state, action) => ({...state, loading: true})
(state, {error}) => ({...state, error, loading: false})
(state, {result:{data}}) => ({...state, ...data, loading: false})