So worth the hassle. If you’re going to do the refactoring make sure you subscribe to data in templates… unless you need FastRender support today then in that case you have to use the router subs. In FlowRouter 3.0 you won’t be able to subscribe in the router anymore (which i’m excited about) so you might as well plan ahead if possible.
If you can leave FlowRouter to just do… routing, the better off you’ll be. Let something else in your app take care of other concerns when possible.
IR is bloated, complex, and in my experience buggy. The reactive problems seal the deal.
Dealing with packages that aren’t compatible will be annoying at best. You can likely fork it and re-wire it for FlowRouter though. IMHO the packages should have abstracted all of the logic so that there was a thin facade adapter for IR and then they could have made another thin facade for FlowRouter… etc… I think Kadira has something for setting head tags too.
Migrating a current project slowly can be done by moving re-running logic out of the router so that it’s not doing much besides routing. Then when this is all done it makes it much easier to just switch.
[quote="shock, post:5, topic:8064"]
I am not exactly sure if it can be done easily per template/component, but it seems possible to rewrite 1 component a time. With having flux state and standard Blaze changes both at same time and just switching components between these 2 systems. Till Blaze would be no more needed.
[/quote]
Yep i’m doing this right now actually. As one part of the app has a bug or needs a new feature I copy/paste the blaze template into JSX, run a find/replace on className
, stub out any template helpers then get a basic React unit test passing. Then re-wire as needed. Usually this means adding to a flux store or watching a new collection to get the data. Tab triggers to spit out boilerplate for this is must have. This is one of my favorites for Refactoring into React: https://www.youtube.com/watch?v=BF58ZJ1ZQxY
As far as Meteor specific things are concerned… my goto strategy is to start out with Reaktor (React facade for FlowRouter), and have a thin React ‘shell’ for each page. This shell page would just basically render a <BlazeTemplate tmpl={Template.about}/>
component. This allows you to use Reaktor and still keep your Blaze pages.
If you are using IR link helpers you’ll need to find/replace as you drop in each page. Doing this for 15 pages only took an hour, including writing a BlazeTemplate component. I also didn’t have much on the filters besides authentication and analytics tracking. This was easily ported with FR triggers.
Then each page gets converted to React eventually as needed. It’s a client app so it has to be done when there’s changes or solves a problem (or bugs). I’m also still using Blaze for things like the Tabular tables package.
Hmmm, are you looking for more the above? Or general react info like the video link? From Blaze to React or Iron Router to Flow Router?
I would also highly suggest tinkering with the open source apps to get a feel what you’re end result will be (most likely it will be different form that).
I’m also using a completely different setup for a new project that’s using react-router and webpack with react-hot-loader (reload per function to retain state), real ES6 modules, and NPM integration. At it’s current state it’s more like a fussy Lamborghini
I’ll have more to post on this setup soon!