ReacJS与猴面包树,如何在卸载组件后释放光标
ReacJS with Baobab, how to release cursor after the component is unmounted
I am new to ReactJS and baobab. Here is what I have:
代码开始:
var stateTree = new Baobab({
outputs: {
campaignList: [],
exportFields: [],
exports: [],
hygiene: [],
exportFormatList: []
}
});
var CampaignEdit = React.createClass({
mixins: [
stateTree.mixin,
React.addons.LinkedStateMixin,
SelectDropdownMixin,
Router.State
],
cursors: {
campaignList: ['outputs','campaignList'],
exports: ['outputs', 'exports']
},
componentDidMount: function() {
this.cursors.campaignList.on('update', this.updateCampaignState);
this.cursors.accountList.on('update', this.updateAccountState);
},
updateAccountState: function() {
var accountList = deref_cursor(this.cursors.accountList, []);
var select_options = this.state.select_options;
for (var i=0; i<accountList.length; i++) {
var account = accountList[i];
select_options['owner_id'][account.id] = account.firstname + ' ' + account.lastname;
}
this.setState({ 'select_options': select_options});
},
render: function() {
/* render the component here */
}
});
:代码结束
但是,当用户切换到另一个组件并返回到此组件时,我收到此错误:"未捕获错误:不变冲突:替换状态(...(:只能更新已装载或已装载的组件。
This is coming up as my current component being loaded is in "UNMOUNTED" state.
My questions is that if the component is already unmounted, why is the unmounted component being reused? Is there a way to avoid this?
发现由于与游标绑定的事件而导致的问题。新增组件将卸载并解绑更新事件。
相关文章:
- 我是否可以检测到javascript正在被卸载(作为调试模式)
- 动态加载和卸载js文件
- 在页面卸载时写入HTML5 FileSystem API存储
- 如何禁用窗口.当计时器超时时,打开卸载警报
- 卸载未触发组件WillUnmount的子级
- ReacJS与猴面包树,如何在卸载组件后释放光标
- 卸载/销毁角延迟加载组件
- redux-form 是 卸载组件后破坏我的状态,什么给了
- 反应如何在组件中正确删除列表器将卸载,为什么我需要在构造函数中绑定
- 组件卸载时取消图像加载
- 我似乎无法使用组件将卸载可靠地删除侦听器
- 如何在路由更改时卸载组件
- 在React组件卸载时移除一个事件监听器
- 卸载React组件
- 有没有办法检查反应组件是否已卸载
- 卸载组件时,React动画不工作
- 如何在挂载/卸载之间保持React组件状态
- React,执行组件's函数导致Redux状态更改,从而卸载组件,此时函数返回
- 反应为什么卸载组件很慢
- 不能卸载React组件,从父组件返回false