Render context
benjamminf opened this issue · 3 comments
I'm not sure exactly what the purpose of the context
parameter is when rendering templates. In the API reference, the only note on this parameter is:
This will pass through every component hierarchy
Does this mean any descendant components initialised in the rendered template will have the context
data passed to it as well?
My first thought was that context
provided a way of passing in extra "global" properties that could be used in templates. After looking through the source I realised this wasn't the case, so I modified my update
methods in all my components like so:
update(state)
{
Object.assign(this.state, state)
super.update(Object.assign({}, this.context, this.state))
}
Is this an appropriate use of the context
parameter?
Looking into some examples, I see context
is generally used to hold actions for state management (redux). This is a much better idea.
Hi,t
You are right, context
is for passing some context (
It's same as reacts contexts: https://facebook.github.io/react/docs/context.html
Ah okay, thanks! I've never used React before, and as far as I know there's no explicit controlling of component context in Vue. Cheers for the link!