Mantra, trying to understand the source of sample blog app

Want to make tutorial about this architecture (nube for nubes) because all the others are out of date. :grin:
Could you help, please? )))
This is the repo.

  1. Cant understand why we have create function here, in stateless newpost component.

    I mean, we have create function here, in action folder.

    Cant connect this two in my head :pensive:
    The only connection is in the routes.js of the core module.

  2. Cant understand what injectDeps does and how NewPost component has access to MainLayoutCtx props(if it has)?

  3. If in NewPost component we call create from actions/posts.js why we do this with only two params?

  4. What else was injected in MainLayoutCtx? )

  1. If you notice, in the route.js file the container for the NewPost component is imported. Containers are used to pass appropriate props & actions to the components/containers according to your app context (LocalState, methods, actions - basically business logic specific to your app)

  2. injectDeps is used to provide both context and actions objects as props to all of your components that you use in the MainLayout component. It uses React’s context feature for this.

  3. Each of your actions are automatically bound with context as the first argument, so that you don’t have to provide it yourself

  4. When the Mantra core package loads your routes, it provides a version of injectDeps which already has context and actions so that you only need to provide the layout component.


It is so so helpful :blush:, thank you very much :sparkler:

For future Mantra questions, you can also ask them on

1 Like