如果props值更改,如何更新视图

时间:2016-02-11 10:02:38

标签: javascript reactjs

类TicketTabDetails,此类负责在单击时显示侧面菜单项的实际内容

class TicketTabDetails extends Component {
  constructor () {
    super();
  }
  render () {
    console.log(this.props.ticketItem);
    let detailedContent = (
        <Section pad="medium">
          {this.props.ticketItem}
        </Section>     
      );
    return detailedContent;
  }
}

类TicketTabData,此类负责选项卡侧面菜单和菜单数据部分

class TicketTabData extends Component {
  constructor (props) {
    super(props);
    this.onFetchTabData = this.onFetchTabData.bind(this);
    this.state = {
      ticketdata : ''
    }
  }
  onFetchTabData(tabdata) {
    this.setState({ ticketdata: tabdata });
  }
  render () {
    return (
      <Split flex="right">
        <Sidebar colorIndex="light-2">
          <BuildSideMenu menuitem={this.props.branch} onFetchTabData = {this.onFetchTabData}/>
        </Sidebar>
        <Article scrollable={true}>
            <TicketTabDetails ticketItem={this.state.ticketdata}/>
        </Article>
      </Split>
    );
  }
}

此类TicketTabDetails无法返回作为属性传递的更新的ticketItem,如果属性值更改,如何更新视图?

0 个答案:

没有答案