0
所以我有以下设置:在React.js页脚 - 实施意见
- 导航条
- 非常嵌套内容,包括向导和部分窗户。
- 页脚是动态的,它的按钮和功能性应该在内容的部分场景中进行更改。
现在,我有一个页脚的商店被修改这样实现:
componentWillMount =() => {
this.setFooterButtons();
//REST OF 'componentWillMount' CODE
}
componentDidUpdate =() => {
//If the uploading step is 'file-properties-editor'
//then there is a view inside the view
//that sets the footer buttons, in other cases,
//the nested views does not change the footer's buttons
//and they are defined here.
if(this.state.uploadStep !== 'file-properties-editor'){
this.setFooterButtons();
}
//REST OF 'componentDidUpdate' CODE
}
setFooterButtons =() => {
footerActions.setFooterButtons([
{
fn: this.props.onBack,
name: 'back',
disabled: this.state.uploadStep === 'uploading'
},
{
fn: this.onJump,
name: 'jump',
class: 'star'
},
{
fn: this.onComplete,
name: 'next'
}
]);
}
的问题是,有存储的来自于各类不同的地方“setFooterButtons”太多调用嵌套视图。
我尝试过的其他事情是添加页脚作为属性的按钮作为属性,但它是非常混乱,以及例如我有一个视图里面,他们都显示不同的页脚。