Re:Designing simpler React components
by amelius on Saturday March 26, 2016 @05:35PM
(#11367568)
Immutable data-structures are useful, but also it is quite a lot of work to transform a codebase written with mutable data-structures into one with immutable ones. This is because mutability is a "viral" property.
[ Parent
| on HN ]
Re:Designing simpler React components
by undershirt on Saturday March 26, 2016 @08:57PM
(#11368309)
It'll depend on the codebase of course, but I think it's a lot less work if you're using the flux frameworks that seem to be popular with modern JS apps.
I think it's interesting that Elm and ClojureScript have chosen immutability as the default. I wonder what other languages have chosen this.
flux + deepFreeze your state just to be safe
you also have Haskell for immutability by default and with no other option :)
An easy way to structure the code with immutable data is to made it essentially read only. Anything can read the data state and that can be shared throughout an application, but to write, you need an explicit function call or event