facebookarchive / react-meteor

React rendering for Meteor apps
948 stars 114 forks source link

Component isn't being destroyed after template is destroyed #48

Closed dearlordylord closed 9 years ago

dearlordylord commented 9 years ago

I have route like this

this.route('teacherSelect', {path: '/teacherSelect', controller: TeacherSelectController});

and a component defined like component in this project example.

When I visit /teacherSelect page, I get component rendered. When I go to another page by any link (placed in iron-router layout inside what component is rendered), new template being rendered, but old one with component still linger on page! : ) Important thing may be that these other templates aren't react-enabled and use Blaze as I introduce this in existing project.

dearlordylord commented 9 years ago

Important thing to add: template really being destroyed - I got log in Template.teacherSelect.destroyed call. So issue should be rephrased into component isn't being destroyed after template is destroyed

dearlordylord commented 9 years ago

Also when I check my template.onRendered this way:

... onRendered(function() {
  var template = this;
  setTimeout(function(){
    console.warn(template)
  }, 3000)
})

It shows that firstNode and lastNode of template are still span (!)

dearlordylord commented 9 years ago

UPD what I do for now is template._reactComponent = React.render(component, template.firstNode); in onRender manually, then React.unmountComponentAtNode(template._reactComponent.getDOMNode()); in onDestroyed.

sarahkevinking commented 9 years ago

I created a pull request for the issue, will use the fork until it is resolved in master.

Thank you @Firfi