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中關閉,所以在切換頁面後鏈接仍在繼續。