과 같이 경로 구조와 다른 비 중첩 된 경로를 통해 componentWillUnmount를 호출 :반응-라우터 : I 반응 라우터를 사용하고
const routes = (
<Router history={browserHistory}>
<Route path="/main" component={MainPage}></Route>
<Route path="/charts/:chartID" component={App}></Route>
</Router>
)
나는 유성 방법에 대한 호출을하려고 할 때 사용자 스위치 "/ charts/: chartID"에서 "/ main"으로 이동하십시오.
componentDidUpdate(){
Meteor.call('test',"update");
} // prints "update"
componentWillUnmount(){
Meteor.call('test',"unmount");
} // nothing happens when url changes
Main.js (서버) : 내가 읽은
Meteor.methods({
'test'(obj){
console.log(obj)
}
})
난 단지 내가 수명주기 방법을 사용하는 방법은 한 번
App.js에서 가능하면 호출 할 이 source에서 구성 요소는 내 상황에서 URL이 변경 될 때 마운트 해제되어야하지만 뭔가를 놓친 것처럼 보일 수 있습니다. 이 문제를 어떻게 해결해야합니까?
도움을 주시면 대단히 감사하겠습니다.