是最新react用的算法選擇,其大概的介紹點擊這裏;react
在現有React中,更新過程當中是同步的(這個js代碼的代碼執行相關)git
In order to do any of this, we first need a way to break work down into units. In one sense, that's what a fiber is. A fiber represents a unit of work.github
That's the purpose of React Fiber. Fiber is reimplementation of the stack, specialized for React components. You can think of a single fiber as a virtual stack frame.算法
In concrete terms, a fiber is a JavaScript object that contains information about a component, its input, and its output.redux
破解JavaScript中同步操做時間過長的方法其實很簡單——分片。 數據結構
React Fiber把更新過程碎片化,每執行完一個更新過程,將控制權交給react,它會根據優先級安排下一次的任務; dom
維護每個分片的數據結構,就是Fiber。異步
參考文件函數
在現有的React中,每一個生命週期函數在一個加載或者更新過程當中絕對只會被調用一次;在React Fiber中,再也不是這樣了,第一階段中的生命週期函數在一次加載和更新過程當中可能會被屢次調用!ui
這些在react fiber中可能執行屢次
這些只能執行一次
fiber新的調度系統,setState都是異步的,因此:
錯誤的姿式
this.setState({ a: this.state.a + this.props.b });
正確的姿式
this.setState((a, b) => ({ a: prevState.a + props.b }))
歡迎來github上 start