React Native簡史

誕生

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

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 fastreact

  • 快速迭代(Rapid iteration cycle):Web 一天兩版,產品迭代週期更短
  • 快速反饋(Immediate testing feedback):Web 發佈當即觸達用戶,A/B test 等實驗結果立等可取,產品演進更快
  • 快速開發(Rapid development velocity):刷新瀏覽器便可生效,沒必要等待從新編譯 App

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

  • 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,就是第三種方案的最終成果git

2015

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

最初只支持 iOS,同年 9 月支持了 Androidweb

2016

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

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

2017

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

另外,還開始了編譯時的性能優化探索,如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 async rendering 能力、簡化 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.

參考資料

有所得、有所惑,真好

關注「前端向後」微信公衆號,你將收穫一系列「用原創」的高質量技術文章,主題包括但不限於前端、Node.js以及服務端技術

本文首發於 ayqy.net,原文連接 http://www.ayqy.net/blog/the-...

相關文章
相關標籤/搜索