boolean shouldComponentUpdate(object nextProps, object nextState) props或state发生改变后执行。如果返回false就不会刷新render。
void componentWillUpdate(object nextProps, object nextState) props或state发生改变后执行。
void componentWillReceiveProps(object nextProps) props发生变化之后执行。
void componentWillUnmount()移除组件时执行
ps1:react 绑定数据模型,使用state来绑定视图数据。通俗来讲就是 input 修改value 要把value = state ,然后修改state。
ps2:由于props和state都会触发render,所以由上层页面获取的数据的改变传入下层页面有可能会导致刷新两次,比如 上一级页面传入新的props,然后props赋予state来修改页面里的值,由于state和props都改变了,所以刷新两次。(不知怎么解决)
ps3:实际项目中使用了UDP链接,而且并没有在componentWillUnmount中关闭,所以在切换页面后链接仍在继续。