跳到主要內容
黯羽輕揚每天積累一點點

React Native 簡史

免費2019-08-25#Tool#react native history#history of react native#ReactNative history#the birth of react native#React Native演进史

React Native 從誕生到現在

誕生

React Native 誕生於 2013 年的 Facebook 內部黑客馬拉松(hackathon):

In the essence of Facebook’s hacker culture, React Native started as a hackathon project in the summer of 2013.

(摘自 In the beginning: React Native’s roots

從 React 說起

隨著 React 的大規模應用,Facebook 越發感受到 React 以及 Web 技術的優勢,希望 Native 開發也能像 Web 一樣 Move fast

  • 快速迭代(Rapid iteration cycle):Web 一天兩版,產品迭代週期更短

  • 快速回饋(Immediate testing feedback):Web 發佈立即觸達用戶,A/B test 等實驗結果立等可取,產品演進更快

  • 快速開發(Rapid development velocity):刷新瀏覽器即可生效,不必等待重新編譯 App

為了達成這個目的,Facebook 嘗試了 3 種方案:

  • WebView:由 Native 提供 WebView 容器,業務用 Web 技術來開發。優勢在於能把 Web 開發體驗一鍋端走,但受限於 Web 技術,體驗無法與 Native 相提並論,最終因性能和擴展性沒有達到預期而作罷

  • Porting React to native:把 React 移植到 Native 實現,一個瘋狂的想法。在 2015 年完成了 iOS 版(ComponentKit),並在 2017 年推出了 Android 版(Litho)。以此讓 Native 開發也能具備 React 的種種優勢,如 UI 可預測性、Flexbox 佈局等。但無法滿足提升開發效率的初衷,一點變動仍要重新編譯,另一方面,這一套與 Web React 並不互通,無法利用 Web 生態中建立在 React 之上的利器(如 Relay

  • Scripting native:透過 JavaScript 呼叫 Native API。既能擁有 Web 開發的快速迭代能力,還不侷限於 Web 技術,同時也沒有脫離 JavaScript 生態,似乎是個完美的方案

React Native,就是第三種方案的最終成果

2015

2015 年 1 月的 React.js Conf 上,這個內部項目首次公布,並在 5 月的 F8 Conference 上正式開源

最初只支援 iOS,同年 9 月支援了 Android

2016

Microsoft UWP 和 Samsung Tizen 的支援,意味著 React Native 從行動端走向了 PC(Win 10)、遊戲機(Xbox One)、手環(Gear Fit 2)、智慧電視(SUHD)甚至全像眼鏡(HoloLens)

此外,開發體驗、性能、 API 能力等都在快速迭代中不斷提升

2017

建立了月度迭代計劃,以及定期召開包括社群團隊在內的月會。性能仍然是一個重要方向,動畫、 List View 等重要更新都涉及性能優化

另外,還開始了 編譯時的性能優化探索,如 Prepack,期望大幅削減 React Native core 的初始化耗時:

We plan to bring the cost of the React Native bridge close to zero via projects like Prepack and more build time processing.

2018

為了更好地支援 Native & React Native 混合 App,核心團隊啟動了 架構升級計劃Fabric),包括重構執行緒模型、支援 React 非同步渲染能力、簡化 React Native core 等大改。同時,Facebook 也計劃開源包括 JSI 在內的一些基礎設施,具體見 Open Sourcing Internals and Updated Tooling

另一方面,開源社群的管理也走向正規化,包括版本管理、 RFC 、交流討論等

2019

在開源社群的參與下,架構升級計劃進展迅速,部分非核心模組從 React Native Core 拆出去獨立維護,並且效果不錯:

These modules are getting more support than they ever did within React Native, showing that this is a great step for the community.

同時,性能優化從未停歇,甚至換用 Hermes 作為 Android 平台的 JS 引擎(之前 Android 也用 JavaScriptCore),以求進一步的性能提升:

Hermes is an open-source JavaScript engine optimized for running React Native apps on Android. For many apps, simply enabling Hermes will result in improved start-up time, decreased memory usage, and smaller app size.

參考資料

評論

暫無評論,快來發表你的看法吧

提交評論