導航:首頁 > 版本升級 > 怎麼查看react版本

怎麼查看react版本

發布時間:2023-02-10 08:53:35

⑴ create-react-app4和5的區別

create-react-app是一種快速構建React應用程序工具,可以自動生成開發環境和配置文件。create-react-app的版本從4.0開始,到目前的5.2。

create-react-app 4.0和5.0之間的主要區別如下:

支持的React版本不同:create-react-app 4.0支持React 16.9及以下版本,而create-react-app 5.0支持React 17及以上版本。

新增的腳本命令:create-react-app 5.0新增了一些腳本命令,如npm start --inspect-brk,用於調試應用程序。

默認使用Webpack 5:create-react-app 5.0默認使用Webpack 5,而create-react-app 4.0使用的是Webpack 4。

⑵ 如何管理React-Native庫的版本

首先安裝了nodejs 4.乏訂催寡詘干挫吮旦經1 版本
然後 安裝了 npm install -g react-native-cli 模塊
安裝 android sdk 並且配置android 環境變數
安裝gradle 環境
進入 這個博客 里邊有 react-native for android 項目,下載下來,然後執行 npm install 先安裝 react 依賴模塊包
打開兩個 命令窗口 1. 一個 執行react-native start ,另一個執行react-native run-android 就可以了

⑶ React新舊版本對比總結歸納(生命周期篇)

我們先來看下React16.0前後生命周期變化的圖片

生命周期圖譜: http://projects.wojtekmaj.pl/react-lifecycle-methods-diagram/

① componentWillMount

② componentWillReceiveProps

③ componentWillUpdate

① UNSAFE_componentWillMount

② UNSAFE_componentWillReceivePorps

③ UNSAFE_componentWillUpdate

① getDerivedStateFromProps

② getSnapShotBeforeUpdate

③ getDerivedStateFromError

④ componentDidCatch

○ 什麼時候調用?

這個方法會在調用 render 方法之前調用,並且在初始掛載及後續更新時都會被調用。它應返回一個對象來更新 state,如果返回 null 則不更新任何內容。

○ 返回值

返回值是必須的,它應該是一個對象,用於更新state; 如果返回值為null,state不更新。

○ 主要用途?

這個生命周期函數是為了替代componentWillReceiveProps存在的,所以在你需要使用componentWillReceiveProps的時候,就可以考慮使用getDerivedStateFromProps來進行替代。主要是將新的props更新到state上

看下邊例子就明白了!

○ 什麼時候調用?

getSnapshotBeforeUpdate() 在最近一次渲染輸出(提交到 DOM 節點)之前調用。

○ 返回值

應返回 snapshot 的值(或 null)

○ 有什麼用途?

它使得組件能在發生更改之前從 DOM 中捕獲一些信息(例如,滾動位置)。此生命周期的任何返回值將作為參數傳遞給 componentDidUpdate()。

此用法並不常見,但它可能出現在 UI 處理中,如需要以特殊方式處理滾動位置的聊天線程等。

○ 什麼時候調用?

此生命周期會在渲染階段後代組件拋出錯誤後被調用,因此不允許出現副作用。

○ 返回值

它將拋出的錯誤作為參數,並返回一個值以更新 state

○ 有什麼用途?

主要用於封裝錯誤邊界用,收集錯誤信息並做對應處理。

以下為具體用法用例

然後你可以將它作為一個常規組件去使用:

○ 什麼時候調用?

此生命周期會在「提交」階段後代組件拋出錯誤後被調用,因此允許執行副作用。

○ 參數

error —— 拋出的錯誤。

info —— 帶有 componentStack key 的對象,其中包含有關組件引發錯誤的棧信息。

○ 返回值

它將拋出的錯誤作為參數,並返回一個值以更新 state

○ 有什麼用途?

主要用於封裝錯誤邊界用,收集錯誤信息並做對應處理。

用例如下:

結論:對於新生命周期③和④作用基本是一致的,都是用於封裝錯誤邊界,收集邊界下後代組件構造函數中發生的錯誤信息並作出對應處理。不同的是調用時間和返回參數。

⑷ RN筆記:RN開發環境+項目依賴

前言 :從前端的發展歷程上看,從切圖仔到全端,註定有舍有得,邊界會越來越大,技術會越來越豐富,貫穿瀏覽器、服務端和移動端多元化發展趨勢。花了一天時間糾結用HTML5+和RN來開發安卓ios雙端,考慮穩定性選擇用RN,做好被虐上整整一個月的心理准備,開發過程中事實也確實如此,坑多慎入。
另外建議當決定要用RN重構應用或者基於RN開發時,盡量提前梳理業務文檔,有條件先組預研發小組,去研究業務實現的可能性,比如說集成外部的sdk,切記原生部分最好要求配合安卓ios朋友一起合作,否則會很難受。
從技術角度,入坑先從vue跳到react,再入react-native。此文章主要記錄項目開發中填坑過程。

react-native init 項目名
tip:react-native 版本更新較快,init默認是最新版本的react-native,目前最新發布版本0.60.0版本(更新修復,支持androidX,完全刪除了WebView,Geolocation...),也可根據需要創建指定版本RN:
react-native init 項目名 --version 0.59.9
進入項目目錄查看react-native版本 :react-native -V

接著在項目目錄下,命令行服務埠 react-native start

點擊啟動按鈕,選擇模擬器就可啟動項目

真機啟動:用usb連接電腦和手機(手機必須在開發者選項下,打開usb調試模式,否則啟動會報錯),在項目目錄下,命令行啟動:
react-native run-android
App安裝完成,node窗口進度條走完即可在手機上運行RN項目。

模擬器與真機開發者菜單主要用到:Reload (重載),Debug JS Remotely(Debug 調試模式,可在瀏覽器中console.log輸出),Enable Hot Reloading(熱更新);
開發者菜單打開方式:
模擬器:ctrl+m , r+r(為reload)
真機:手機搖一搖,或者左鍵長按

根據項目需要可選擇安裝依賴插件,示例項目依賴

依賴安裝方法:
yarn install //安裝全部依賴
yarn add 依賴名 //安裝單個依賴
yarn add 依賴名@版本號 //安裝依賴某個版本
yarn remove 依賴名 //刪除依賴 ,刪除依賴後,需要把安卓ios原生文件中刪除依賴

需要依賴原生庫
react-native link 依賴內一次性全部鏈接
react-native link 依賴名 鏈接某一個庫

假設,根據項目需要修改了依賴包源碼,在項目根目錄復制修改源碼的包,
在pagejson.json文件修改文件安裝路徑。

⑸ react native gradle怎麼升級

更新版本的React Native將會讓你訪問更多的APIs, 這樣我們可以去使用更多的APIs,視圖Views,以及開發者工具以及其他一些好用的東西。瀏覽版本更新日誌就會發現整體FB官方開發進度還是非常緊張的,這樣就很容易導致舊版本會出現不能用的情況,後期可能會出現不可預料的情況,這邊建議大家盡量更新最新正式版本。
我們大家都知道一個React Native項目使用Android項目,iOS項目和JavaScript項目三部分進行組成的,而且三者都關聯打包在npm包內的,所以該項目版本進行更新是比較繁瑣的。下面我來給大家講解一下React Native項目的升級步驟。
一、查看當前版本
[plain] view plain
<span style="font-family:SimSun;font-size:14px;">pengchengxiang@ubuntu:~/AwesomeProject$ react-native --version
react-native-cli: 0.2.0
react-native: 0.22.2</span>
二、查看最新的版本
[plain] view plain
<span style="font-family:SimSun;font-size:14px;">pengchengxiang@ubuntu:~/AwesomeProject$ npm info react-native
{ name: 'react-native',
'dist-tags': { latest: '0.25.1', next: '0.26.0-rc' },
versions:
[ '0.0.0',
'0.0.5',
... ...
'0.24.1',
'0.25.0-rc',
'0.25.1',
'0.26.0-rc' ],
maintainers:
... ...
dist:
{ shasum: '',
tarball: 'https://registry.npmjs.org/react-native/-/react-native-0.25.1.tgz' },
directories: {} }</span>
三、升級依賴的版本
[plain] view plain
<span style="font-family:SimSun;font-size:14px;">pengchengxiang@ubuntu:~/AwesomeProject$ npm install --save [email protected]

> [email protected] install /home/pengchengxiang/AwesomeProject/node_moles/react-native/node_moles/ws/node_moles/bufferutil
> node-gyp rebuild

make: Entering directory `/home/pengchengxiang/AwesomeProject/node_moles/react-native/node_moles/ws/node_moles/bufferutil/build'
CXX(target) Release/obj.target/bufferutil/src/bufferutil.o
SOLINK_MODULE(target) Release/obj.target/bufferutil.node
COPY Release/bufferutil.node
make: Leaving directory `/home/pengchengxiang/AwesomeProject/node_moles/react-native/node_moles/ws/node_moles/bufferutil/build'

> [email protected] install /home/pengchengxiang/AwesomeProject/node_moles/react-native/node_moles/ws/node_moles/utf-8-validate
> node-gyp rebuild

make: Entering directory `/home/pengchengxiang/AwesomeProject/node_moles/react-native/node_moles/ws/node_moles/utf-8-validate/build'
CXX(target) Release/obj.target/validation/src/validation.o
SOLINK_MODULE(target) Release/obj.target/validation.node
COPY Release/validation.node
make: Leaving directory `/home/pengchengxiang/AwesomeProject/node_moles/react-native/node_moles/ws/node_moles/utf-8-validate/build'

> [email protected] postinstall /home/pengchengxiang/AwesomeProject/node_moles/react-native/node_moles/yeoman-generator/node_moles/cross-spawn/node_moles/spawn-sync
> node postinstall

npm WARN optional dep failed, continuing [email protected]
[email protected] node_moles/react-native
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── word[email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected] ([email protected])
├── [email protected] ([email protected])
├── [email protected] ([email protected])
├── [email protected] ([email protected])
├── [email protected] ([email protected], [email protected])
├── [email protected] ([email protected], [email protected], [email protected], [email protected], [email protected])
├── [email protected] ([email protected])
├── [email protected] ([email protected])
├── [email protected]
├── [email protected] ([email protected], [email protected])
├── [email protected] ([email protected], [email protected])
├── [email protected] ([email protected])
├── [email protected] ([email protected], [email protected])
├── [email protected] ([email protected], [email protected], [email protected], [email protected], [email protected], [email protected])
├── [email protected] ([email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected])
├── [email protected] ([email protected], [email protected])
├── [email protected]
├── [email protected] ([email protected], [email protected], [email protected], [email protected])
├── [email protected]
├── [email protected] ([email protected], [email protected], [email protected], [email protected])
├── [email protected] ([email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected])
├── [email protected] ([email protected], [email protected], [email protected], [email protected])
├── [email protected] ([email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected])
├── [email protected] ([email protected])
├── [email protected] ([email protected], [email protected], [email protected], [email protected])
├── [email protected] ([email protected], [email protected])
├── [email protected] ([email protected], [email protected], [email protected], [email protected])
├── [email protected] ([email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected])
├── [email protected] ([email protected])
├── [email protected] ([email protected], [email protected], [email protected], [email protected])
├── [email protected]
├── [email protected] ([email protected], [email protected], [email protected], [email protected])
├── [email protected] ([email protected], [email protected], [email protected], [email protected], [email protected])
├── [email protected]
├── [email protected] ([email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected])
├── [email protected] ([email protected], [email protected])
├── [email protected] ([email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected])
└── [email protected] ([email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected])</span>

⑹ 怎麼看react build是什麼版本

安裝node.js 由於nodejs中使用GYP進行項目構建管理,而GYP是基於Python的構建工具。因此,需要先安裝Python。此外,在Windows系統下,nodejs採用GYP來生成Visual Studio Solution文件後,需要通過C++的編譯器將其編譯為二進制文件。因此,又需要先安裝C++編譯環境。最後,安裝nodejs【牆裂建議選擇stable穩定版】。一系列安裝完成後,進入cmd,輸入"npm"指令後回車,出現形同以下畫面內容,則安裝成功。 需要配置path,加入如:E:\Android\Python27;C:\Users\che\AppData\Roaming\npm;

⑺ react native realse版本apk 怎麼看日誌,

訪問App內的開發菜單
你可以通過搖晃你的設備或者選擇iOS模擬器的Hardware菜單中的「Shake Gesture」來打開開發者菜單。你還可以在app運行於iPhone模擬器時使用Command+D快捷鍵,或者在運行Android模擬器時使用Command+M快捷鍵。

⑻ 如何查看 jpush-react-native 的版本

首先確保你的電腦和手機設備在同一個Wi-Fi環境下。 其次你需要開啟USB調試才能在你的設備上安裝你的APP。一定要確定你已經打開設備的USB調試開關! 確保你的設備已經被成功連接,可以輸入adb devices核實

閱讀全文

與怎麼查看react版本相關的資料

熱點內容
maya粒子表達式教程 瀏覽:84
抖音小視頻如何掛app 瀏覽:283
cad怎麼設置替補文件 瀏覽:790
win10啟動文件是空的 瀏覽:397
jk網站有哪些 瀏覽:134
學編程和3d哪個更好 瀏覽:932
win10移動硬碟文件無法打開 瀏覽:385
文件名是亂碼還刪不掉 瀏覽:643
蘋果鍵盤怎麼打開任務管理器 瀏覽:437
手機桌面文件名字大全 瀏覽:334
tplink默認無線密碼是多少 瀏覽:33
ipaddgm文件 瀏覽:99
lua語言編程用哪個平台 瀏覽:272
政采雲如何導出pdf投標文件 瀏覽:529
php獲取postjson數據 瀏覽:551
javatimetask 瀏覽:16
編程的話要什麼證件 瀏覽:94
錢脈通微信多開 瀏覽:878
中學生學編程哪個培訓機構好 瀏覽:852
榮耀路由TV設置文件共享錯誤 瀏覽:525

友情鏈接