React-router 渲染事件
React-router rendered event
react-router 是否在渲染组件时触发事件?我没有在 github 维基页面中找到它。
一个就像 Angular ui-router 中的这个事件:
$viewContentLoaded - fired once the view is loaded, after the DOM is rendered. The '$scope' of the view emits the event.
在您路由到的组件上使用 componentDidMount
生命周期方法。
var YourComponent = React.createClass({
componentDidMount: function() {
// Code here
},
componentWillUnmount: function() {
},
render: function() {
return (
<div>
</div>
);
}
});
module.exports = YourComponent;
react-router 是否在渲染组件时触发事件?我没有在 github 维基页面中找到它。
一个就像 Angular ui-router 中的这个事件:
$viewContentLoaded - fired once the view is loaded, after the DOM is rendered. The '$scope' of the view emits the event.
在您路由到的组件上使用 componentDidMount
生命周期方法。
var YourComponent = React.createClass({
componentDidMount: function() {
// Code here
},
componentWillUnmount: function() {
},
render: function() {
return (
<div>
</div>
);
}
});
module.exports = YourComponent;