Answer the question
In order to leave comments, you need to log in
How to switch from blaze to react?
Good afternoon! Our entire application is written in Iron:Router + Blaze Templates. After the release of Flow Router, we want to switch to it. However, it works great with React, which we would also be interested in implementing.
So, subject: how to transfer the project from blaze to react "in parts"? Interested in intelligent approaches. It's so clear that you can freeze the project and rewrite it using React.
UPDATE:
At the moment I wrote the following wrapper:
ReactToBlaze = function(templateName, component) {
if(Meteor.isServer) return; // Blaze не пашет на сервере
var templateClass = new Template(templateName, () => new HTML.DIV);
Template[templateName] = templateClass;
templateClass.onRendered(function() {
this.autorun(() => {
var data = Template.currentData() || {};
var c = React.createElement(component, data);
c._meteorTemplate = this;
this._reactComponent = ReactDOM.render(c, this.firstNode);
});
});
templateClass.onDestroyed(function() {
var template = this;
var res = ReactDOM.unmountComponentAtNode(ReactDOM.findDOMNode(template._reactComponent).parentElement);
if(!res) {
console.error('Не удалось размонтировать элемент');
}
});
return templateClass;
};
Answer the question
In order to leave comments, you need to log in
I can express general considerations - include react in the project and, in the presence of the old technology, gradually rewrite the application in parts to the new one, and immediately use react so that there is no need to redo something later. For some time, react and blaze will work in parallel, then there will be only one react.
No need to freeze. Alternatively, rewrite the project, then install the update.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question