kadirahq / mantra

Mantra - An Application Architecture for Meteor
https://kadirahq.github.io/mantra/
978 stars 52 forks source link

Progressive migration into mantra #157

Closed aykutyaman closed 8 years ago

aykutyaman commented 8 years ago

I want to migrate my app from Blaze to React using Mantra Spec. I am trying to migrate progressively, so I have to run Blaze and React at the same time. I had an issue with the mount and unmount of the React components. When I move from the route, which renders React component, in a different route which renders Blaze, React part does not unmount. So I have something like this in my DOM: screenshot_2016-03-19_14-19-25

aykutyaman commented 8 years ago

This is what I found, and it works. So I am gonna close the issue.

// Blaze part
FlowRouter.route('/users/profile/:_id', {
  name: 'user_profile',
  action() {
    var reactRoot = document.getElementById('react-root');
    if (reactRoot) {
      ReactDOM.unmountComponentAtNode(reactRoot);
    }

    BlazeLayout.render('App_layout', {main: 'user_profile'});
  }
});
// React part
FlowRouter.route('/sales', {
    name: 'sales',
    action() {

     BlazeLayout.reset();

      mount(MainLayoutCtx, {
    content: () => (<div>hello</div>),
      });
    },
  });