React Native 踩坑

1.react-native ListView的屬性flexWrap為wrap不起作用解決之道

2.React Native 0.32以下版本Xcode8報(bào)錯(cuò)解決辦法

2.1 'RCTRootView.h' file not found

  • cd到這個(gè)項(xiàng)目中,執(zhí)行npm install react-native
  • 此項(xiàng)目中還有其他依賴(lài),執(zhí)行npm install,即可添加所有依賴(lài)


如果運(yùn)行還有錯(cuò)誤,請(qǐng)參考以下

2.2 RCTSRWEBSOCKET.M報(bào)錯(cuò)
Ignoring return value of function declared with warn_unused_result attribute
這個(gè)報(bào)錯(cuò)在此文件中有兩處,代碼
SecRandomCopyBytes(kSecRandomDefault, sizeof(uint32_t), (uint8_t *)mask_key);
修改為
(void)SecRandomCopyBytes(kSecRandomDefault, sizeof(uint32_t), (uint8_t *)mask_key);

2.3 RCTSCROLLVIEW.M 報(bào)錯(cuò)
Use of undeclared identifier '_refreshControl'; did you mean 'refreshControl'?

@implementation RCTCustomScrollView { __weak UIView *_dockedHeaderView; RCTRefreshControl *_refreshControl; // 加入此行 }


重新打開(kāi)項(xiàng)目運(yùn)行

3.React Native iOS 之Could not connect to development server
將項(xiàng)目中的

jsCodeLocation = [NSURL URLWithString:@"http://localhost:8081/index.ios.bundle?platform=ios&dev=true"];

改為本地IP

jsCodeLocation = [NSURL URLWithString:@"http://127.0.0.1:8081/index.ios.bundle?platform=ios&dev=true"];

PS:127.0.0.1為本地的IP

reason:做本地局域網(wǎng)開(kāi)發(fā)環(huán)境,大部分都會(huì)做服務(wù)器映射處理,localhost 被指向特定的IP 而不是本機(jī)的127.0.0.1, 就會(huì)出現(xiàn)這樣的問(wèn)題。
4.項(xiàng)目開(kāi)始運(yùn)行報(bào)錯(cuò)



原因一:
先前運(yùn)行過(guò)其它的React-Native項(xiàng)目。
解決辦法:
退出終端程序,重新運(yùn)行項(xiàng)目即可
原因二:
AppDelegate.m文件中



index.iOS.js文件中

兩個(gè)文件中MyProject字段設(shè)置不一樣。

解決辦法:
將字段設(shè)為一樣的字符即可。

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容