Raynos / mercury

A truly modular frontend framework
http://raynos.github.io/mercury/
MIT License
2.82k stars 143 forks source link

Immutable props #184

Open mpal9000 opened 8 years ago

mpal9000 commented 8 years ago

What is the prefered way to handle transparently or with minimal boilerplate immutable props in mercury? By props I mean an object that you provide to the render function of a descendant component, so you can affect it without touching its state from the owner. I can always use separate arguments, but I prefer an object, because usually there are more than one or two values and also I like to mimic the h() api. A not pretty way is to use a memoized function, with a single cache "slot", which will return the props object, based on some primitive arguments. That is ok for the descendant which will receive the object argument, but not even close to transparent for the owner component. By transparent I mean at the level of how we handle/embed state.