Ваш реквизит компонента, отображаемого переменной состояния, не обновляется, поскольку переменная не обновляется при каждом отображении, а только при вызове setState,
Вместо этого следует отображать страницы условно или использовать маршрутизатор.Также вы можете просто включить обработчик и передать ему страницу, для которой он нужен, в качестве параметра
При условном рендеринге ваш код будет выглядеть как
class ManagerTeam extends Component {
constructor(props) {
super(props)
this.initComponent = this.initComponent.bind(this)
this.showPage = this.showPage.bind(this)
this.initComponent()
}
initComponent() {
this.updateData(this.props)
this.state = {
currentpage: <ManagerTeamVisaoGeral teamList={this.teamList}/>
}
}
updateData(props) {
this.teamList = props.userTeams.list
}
showPage(page) {
this.setState({
currentpage: page
})
}
componentWillReceiveProps(nextProps) {
this.updateData(nextProps)
}
render() {
return (
<div>
<SimpleNavBar user={this.props.user} updateArtifacts={this.props.updateArtifacts} updateManagerTeams={this.props.updateManagerTeams}/>
<NavBar navBarTitle='Equipas' menuOptions={['Visão Geral', 'Membros', 'Tarefas', 'Report']} loadOptions={[this.showVisaoGeral, this.showTeamMembros, this.showTeamTarefas, this.showTeamReport]}/>
<Sidebar activePage="team" isManager={true}/>
{this.state.currentpage === 'Visão Geral' && <ManagerTeamVisaoGeral teamList={this.teamList}/>}
{this.state.currentpage === 'Membros' && <ManagerTeamMembros/>}
{this.state.currentpage === 'Tarefas' && <ManagerTeamTarefas/>}
{this.state.currentpage === 'Report' && <ManagerTeamReport/>}
</div>
)
}
}