Meteor React official architecture with 1.3?

Hey,

I will soon be starting a rather large project and I spent the last few days looking through most of the Meteor/React related stuff.

As many of you know there are a ton of different architectural styles that can be used in combination with React and Meteor.

I worked through the Meteor + React 2.0 example from Ken Rogers which embraces Mantra.
I also looked at the 1.3 version of the Meteor Guide but it seems like the React sections still needs a bit of working on.

Mixins seem to be gone with 1.3 (unfortunately they are still used in the react tutorial which is the most official Meteor documentation besides the guide it seemsā€¦but its for 1.2 so makes sense i guessā€¦)

I also looked at github discussion between Meteor devs, Mantra enthusiasts, redux, flux etc. which donā€™t seem to point in a particular directionā€¦
I know that Meteor wants to give its devs as many choices as possible, but with the release of 1.3 will it be likely that they recommend a certain architecture style for react/meteor apps? Basically something to replace their mixinsā€¦it does not have to be as detailed as for example Mantra spec is.

Thanks!

1 Like

Have you looked at the 1.3 guide preview?

2 Likes

thanks @josmardias . is there any preview tutorial for Meteor 1.3?

1 Like

Hey thanks for the reply

Yes I have looked at that but I feel it is still very little information. Basically just says to use containers instead of mixinsā€¦ I feel itā€™s still way too open

1 Like

Take a look at the react branch of the todo example on Meteorā€™s GitHub. Not a perfect implementation of the guide, but should get you most of the way there! :slight_smile:

1 Like

If you are talking about ā€œfuture proofā€ and ā€œtrendā€, yes, for now containers are the way to go, mixins will not be supported by React in the near future.

The Guide says

However, the guide is an attempt to document best practices and community conventions, so we hope that the majority of the Meteor community will benefit from adopting the practices documented here.

So, I think itā€™s better to follow itā€™s instructions when possible. Youā€™ll probably have to search stuff outside of it as well, keep posting questions and suggestions so it can be improved.

And yes, itā€™s missing a lot of information (about redux for example, maybe in the future?).

I can only answer about mixins for now :frowning:

Yaā€¦It would be nice if Meteor would ā€œendorseā€ certain architectures (and it could be more than one)ā€¦similar to what they did with React/Angular/Blaze official support.

For example, and this is purely meant as an example, MDG say follow the Mantra spec then people starting larger projects who have to make decisions about the structure of their app could state a path with more confidence because it is officially backed.

Right now its more like use containers (which is the react way these days anyways) and do whatever you want architecture wise.

I guess this goes back to ā€œToo opinionated vs too much freedomā€

If anyone starting a larger project (with Meteor 1.3 / React) could comment on their architecture that would be helpful.

Primarily how much confidence can you put into something like Mantra at this point, do you think meteor will ever endorse it or provide their own official alternative?

Thanks

1 Like

The React article in the Meteor 1.3 guide is just one small part! Itā€™s specifically just about React integration. When it comes to architecture, you should look at some of the other articles (note that these are still drafts, and will be finalized soon):

  1. App structure and directory layout: https://github.com/meteor/guide/issues/273
  2. Testing: https://github.com/meteor/guide/pull/244
  3. Data loading (includes client-side data): http://guide.meteor.com/v1.3/data-loading.html

There are some suggestions about the React article here, maybe join the discussion: https://github.com/meteor/guide/pull/263

Oh, and BTW about Redux - if we think Redux is a good idea for React, I think it would be good for Blaze and Angular as well. I donā€™t think it should be a React-specific thing.

4 Likes

Thanks for the additional info.

I do think a specific guide for how to integrate architectural choices such as redux (probably the most popular choice with react currently) with Meteor are very appropriate to be included in the guide.

Sure redux does not have any ties to Meteor but I do not think that excludes it of being part of the Meteor guide.

Just saw this post

Seems to confirm that people really really want these kind of examples / documentation and if it were part of the official guide (even if it is treated as an addon) thatā€™d be just a really valuable resource

I totally agree with that. It seems like some sort of state management tool is a must for more complex apps, and it seems like Redux is the one at the moment. Working out how, and particularly what, of Meteor to integrate with Redux is a bit of a head-scratcher though, some official guidance there would probably save a lot of people a lot of time.

The traffic stats on the simple CRM repo appear to confirm that:

I hope we can get Simple CRM to a standard where it can be good enough to be one of the main examples for Meteor/React/Redux. I tried to follow the Guide when writing it, but obviously there is no officially blessed approach for Redux as yet.

@sashko mentioned the need for thorough tests to be included in example apps on the most recent Transmission which I totally agree with, thatā€™s next on the agenda for Simple CRM.

4 Likes

The Redux store does a lot of the same things as Minimongo so I tried an experiment which removes the use of Minimongo entirely. It works great if you donā€™t need optimistic UI. If you do need optimistic UI then itā€™s a terrible idea.

Here is the example redux app : https://github.com/looshi/redux-ddp

Iā€™d love to see a canonical architecture for Meteor emerge around something like Redux patterns.

1 Like

What would be the benefit of this over what we have now?

I think you want to give devs a patterns they can follow. Which does not mean it has to be the only one of course.

For example if you include a section in the guide detailing a React/Meteor/Redux architecture and maybe include a sample app that implements it (including tests) its easy for devs who want to follow the pattern.

Does everyone who uses Meter/React have to follow that pattern? Of course not.

Sample apps that are not really built out and do not have support from Meteor are just going to add to the endless array of options.

Out of interest @sashko what are your arguments against this?

Oh, I agree with ā€œcanonical architectureā€. Iā€™m just wondering about ā€œaround something like Redux patterns.ā€

@sashko By ā€˜Redux patternsā€™ I mean UI communication via events with payloads. In Redux the term is ā€˜Actionā€™. The pattern is loosely described in Mantra state management section https://kadirahq.github.io/mantra/#sec-State-Management which is great, but itā€™s not obvious how to actually implement it.

While MVVM has the popular View Model package, Redux-style Meteor apps havenā€™t seen a clear winner emerge ( that Iā€™m aware of ). But, that could also be due to React changing a lot, it might just be too soon.

1 Like

I think the benefit is that Redux scales up well and there are lots of examples out there. So if people adopt that architecture, then their apps should be more manageable and maintainable as they grow and when they hit questions they have the wider JS community to refer to, not just the Guide. I might have misunderstood the question though.

Edit: agree with @looshi, maybe itā€™s too soon. It does feel like Flux (i.e. action, payload, etc) is the new MVW though.

1 Like

Minimongo and Redux definitely bring their own advantages to the table. For data, Iā€™m using 100% Mongo/Minimongo. For my projects, Redux is solely in charge of:

  • UI state
  • Form states
  • Maintaining state for sets of actions that are committable (e.g. with a ā€œapplyā€ or ā€œsaveā€ button, which then saves to MongoDB)
  • Anything that needs undo/redo functionality
2 Likes

Not sure about a whole redux, but at least, putting all actions(db calls, sessions, etc) in one action folder with index, as it does redux, seems as a really good pattern.

2 Likes

Thatā€™s really well put, I hadnā€™t crystallized it into that neat a list in my mind yet.

Looking at my code Iā€™m the same, and I think @abhiaiyer is doing the same too judging by the How we Redux series.

1 Like