-
Notifications
You must be signed in to change notification settings - Fork 52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
What are the advantages of using 'injectDeps' to load the layout into the route? #145
Comments
The only difference is that with injectDeps you have the context available in your |
Which context? The application context defined in client/configs/context.js? How do I access it from my layout? I'm trying to get the current route from FlowRouter in my layout. Can't figure out how to get FlowRouter from the app context in my layout component. |
U can get context from first argument in composer function in your container, like so https://github.com/mantrajs/mantra-sample-blog-app/blob/master/client/modules/core/containers/postlist.js#L5 , and get FlowRouter (or Meteor, or Collections etc) from object returned by context() call. |
Yeah, I knew how to access the application context from the container, but I could not figure out how to access it from my main layout template. Last night, I finally figured it out.
The key was to define AppLayout.contextTypes. Once that is defined, the React context gets passed as the second parameter to the layout component. Mantra's app context gets passed inside that, as simply 'context'. So, reactContext.context is the Mantra app context. |
Earlier, without using Mantra, I used this method to load the layouts :
But when following a tutorial, I saw they using
injectDeps
to load the layout. What is the difference and what's the most preferred method?The text was updated successfully, but these errors were encountered: