How properly migrate from Blaze to React?


#1

Hello!

I want to try React in one of my projects built with meteor+blaze+flowRouter. How can i properly migrate to React?
Now i have two layouts (main and admin) rendered using BlazeLayout. All subscriptions are made in templates only. And of course spiderable package.

So i want to change user part of frontend first (and to use ssr). Can BlazeLayout and ReactLayout coexist in “hybrid mode”? For example now i render personel with BlazeLayout.render('mainLayout', {main: 'personel'});, but how can i render it, if my mainLayout become React component?
Is it possible to migrate one view after another, or i need to rewrite all at once?


#2

Blaze and React can coexist perfectly. In fact, if you look at the official MDG React tutorial they do just that with the Accounts.ui package. They wrap the blaze template within a React component.

Adding user accounts

So in terms of migrating your app, yes you can convert one Blaze template at a time into a React component. Take your time.


#3

Maybe this thread is interesting for you too.


#4

You can also use the

meteor add react-template-helper

utility to start by making some of your stuff React components.


#5

Checkout this video on migrating to React. In a nutshell you start at the leaf nodes and then pass the blaze data down into it. Then just keep working upward until you hit the router and at that point you can use react-layout to render the component.

You can also use a helper like this or the more simple way is to just use React.render in the blaze onRender function.

-https://www.youtube.com/watch?v=BF58ZJ1ZQxY


#6

Thank you for the answers!