我在日志中得到这个:
RCTBridge需要dispatch_sync来加载RCTDevLoadingView.这可能会导致死锁
这导致了React中呈现的内容导致对齐问题的问题.
(参见附件截图1)截图与问题
这是随机发生的,因为所有屏幕都没有显示对齐问题.
(见附件截图2)截图没有问题
我使用样式组件进行布局:
return(
this.props.lastComponent ?
<CommentList marginLeft={this.props.marginLeft}>
<CommentUserPicWrapper imageWidth={this.props.imageWidth}>
{this.props.imageType === 'URL' ? <CommentUserPic source={{uri:this.props.uri}} imageWidth={this.props.imageWidth} onLoad={this.handleLoad}/> : <CommentUserPic source={require('../../img/defaultProfPic.png')} imageWidth={this.props.imageWidth} onLoad={this.handleLoad}/>}
{
this.state.loading ? null : <ActivityIndicator style={{position:'absolute'}}/>
}
</CommentUserPicWrapper>
<CommentDetails borderStatus={true} marginLeft={this.props.marginLeft}>
<CommentUserName>{this.props.userName} says</CommentUserName>
<CommentUserContent>{this.props.UserContent}</CommentUserContent>
<CommentUserDate><Text>{this.props.commentDate}</Text> at <Text>{this.props.commentTime}</Text>MST</CommentUserDate>
</CommentDetails>
<CommentReply onPress={this.replyClicked} borderStatus={true} underlayColor='transparent'>
<CommentReplyText>Reply</CommentReplyText>
</CommentReply>
</CommentList>
:
<CommentList marginLeft={this.props.marginLeft}>
<CommentUserPicWrapper imageWidth={this.props.imageWidth}>
{this.props.imageType === 'URL' ? <CommentUserPic source={{uri:this.props.uri}} imageWidth={this.props.imageWidth} onLoad={this.handleLoad}/> : <CommentUserPic source={require('../../img/defaultProfPic.png')} imageWidth={this.props.imageWidth} onLoad={this.handleLoad}/>}
{this.state.loading ? null : <ActivityIndicator style={{position:'absolute'}}/>}
</CommentUserPicWrapper> …
Run Code Online (Sandbox Code Playgroud) 从babel 6升级到babel 7的现有反应原生项目的步骤是什么?
这些是旧的依赖项:
"dependencies": {
.........
"babel-plugin-transform-runtime": "^6.23.0",
"babel-preset-latest": "^6.24.1",
"babel-preset-stage-0": "^6.24.1",
"babel-register": "^6.24.1",
"prop-types": "^15.5.10",
"react": "16.3.1",
"react-native": "0.55.4",
"react-redux": "5.0.7",
"redux": "^4.0.0",
"redux-actions": "^2.6.1",
"redux-mock-store": "^1.5.1",
"redux-persist": "^5.10.0",
"redux-thunk": "^2.1.0",
},
"devDependencies": {
"babel-eslint": "^8.2.2",
"babel-plugin-syntax-object-rest-spread": "^6.13.0",
"babel-plugin-transform-object-rest-spread": "^6.23.0",
"babel-preset-react-native": "^4.0.0",
"babel-preset-react-native-stage-0": "^1.0.1",
"eslint": "^4.18.1",
"eslint-config-airbnb": "^17.0.0",
"eslint-plugin-flowtype": "^2.46.1",
"eslint-plugin-import": "^2.14.0",
"eslint-plugin-jsx-a11y": "6.1.1",
"eslint-plugin-react": "^7.4.0",
"gulp": "^3.9.0",
"gulp-eslint": "4.0.2",
"gulp-mocha": "6.0.0",
"jest": "^23.5.0",
.....
},
Run Code Online (Sandbox Code Playgroud)
您需要执行哪些步骤才能进行此更新?新的依赖项应该如何?
对于我(在阅读了babel doc之后),我应该做些什么才能进行此升级,运行命令以及应该在依赖项中添加什么以及devDependencies中的内容.
另外,对于我来说,babel 6和babel 7之间的区别在于反应原生项目中的JS代码发生了什么.
请不要只回复babel doc或react-native 0.57更改日志的链接.
我需要至少一些基本步骤来进行此升级以及基于babel 7的RN项目的package.json示例.
RN 0.57.1
RN-cli 2.0.1
xCode:9.4.1(9F2000)或xCode 10
在RN从0.56更新到0.57.0(或0.57.1)后,我得到了很多could not build module 'CoreFoundation'
或could not build module Foundation
或limits file not found
我完全按照RN doc的步骤进行了此更新.
我尝试删除ios/build
文件夹,清理缓存,重新安装一切,但没有任何工作.
▸构建BunteMobile/OneSignalNotificationServiceExtension [Debug]▸检查依赖关系▸编译NotificationService.m
/Users/myuser/Desktop/projects/mobileapp/ios/../node_modules/react-native/ReactCommon/fabric/graphics/platform/ios/float.h:8:10:'limits'文件未找到
#include <limits>
/Users/myuser/Desktop/projects/mobileapp/ios/../node_modules/react-native/ReactCommon/fabric/graphics/platform/ios/float.h:8:10:'limits'文件未找到
#include <limits>
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.4.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.h:6:10:无法构建模块'CoreFoundation'
#include <CoreFoundation/CoreFoundation.h>
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.4.sdk/System/Library/Frameworks/Security.framework/Headers/SecBase.h:28:10:无法构建模块'CoreFoundation'
#include <CoreFoundation/CFBase.h>
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.4.sdk/System/Library/Frameworks/CFNetwork.framework/Headers/CFNetwork.h:18:10:无法构建模块'CoreFoundation'
#include <CoreFoundation/CoreFoundation.h>
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.4.sdk/System/Library/Frameworks/UserNotifications.framework/Headers/NSString+UserNotifications.h:8:9:能不构建模块'基础'
#import <Foundation/Foundation.h>
如果我删除了OneSignalNotificationServiceExtension而不是7个错误,那么我在项目的其他部分会得到另外15个错误:
/Users/myuser/Desktop/projects/mobileapp/ios/../node_modules/react-native/ReactCommon/fabric/graphics/platform/ios/float.h:8:10:'limits'文件未找到
#include <limits>
/Users/myuser/Desktop/projects/mobileapp/ios/../node_modules/react-native/ReactCommon/fabric/graphics/platform/ios/float.h:8:10:'limits'文件未找到
#include <limits>
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.4.sdk/System/Library/Frameworks/Foundation.framework/Headers/Foundation.h:6:10:无法构建模块'CoreFoundation'
#include <CoreFoundation/CoreFoundation.h>
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.4.sdk/System/Library/Frameworks/Security.framework/Headers/SecBase.h:28:10:无法构建模块'CoreFoundation'
#include <CoreFoundation/CFBase.h>
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator11.4.sdk/System/Library/Frameworks/CFNetwork.framework/Headers/CFNetwork.h:18:10:无法构建模块'CoreFoundation'
#include <CoreFoundation/CoreFoundation.h>
/Users/myuser/Desktop/projects/mobileapp/ios/build/Build/Products/Debug-iphonesimulator/include/React/RCTBridgeModule.h:8:9:无法构建模块'基础'
#import <Foundation/Foundation.h>
我找到的唯一解决方法是将RN降级回0.56 ......
根据RN团队的回答来自 https://github.com/facebook/react-native/issues/21482
将所有babel deps更改为7应该可以解决问题,但即使在npx babel-ugrade -w
重新安装节点模块+缓存清理后,我也会遇到相同的错误.
但仍然是同样的问题. …
的DEP:
"native-base": "2.3.5",
"react": "16.0.0",
"react-native": "0.50.4",
"react-native-admob": "^2.0.0-beta.3",
Run Code Online (Sandbox Code Playgroud)
从RN 0.45更新到0.50并且RN-Admob从1.3.2更新到2.0.0-beta.3
当尝试使用react-native run-android构建时
/node_modules/react-native-admob/android/src/main/java/com/sbugert/rnadmob/RNAdMobInterstitialAdModule.java:117:
错误:找不到符号ArrayList list = nativeArray.toArrayList();
Run Code Online (Sandbox Code Playgroud)^ symbol: method toArrayList() location: variable nativeArray of type
ReadableNativeArray /Users/dobre/Desktop/projects//node_modules/react-native-admob/android/src/main/java/com/sbugert/rnadmob/RNAdMobRewardedVideoAdModule.java:129:
错误:找不到符号ArrayList list = nativeArray.toArrayList();
Run Code Online (Sandbox Code Playgroud)^ symbol: method toArrayList() location: variable nativeArray of type
ReadableNativeArray /Users/dobre/Desktop/projects//node_modules/react-native-admob/android/src/main/java/com/sbugert/rnadmob/RNPublisherBannerViewManager.java:252:
错误:找不到符号ArrayList list = nativeArray.toArrayList();
Run Code Online (Sandbox Code Playgroud)^ symbol: method toArrayList() location: variable nativeArray of type
ReadableNativeArray /Users/dobre/Desktop/projects//node_modules/react-native-admob/android/src/main/java/com/sbugert/rnadmob/RNPublisherBannerViewManager.java:271:
错误:找不到符号ArrayList list = nativeArray.toArrayList();
Run Code Online (Sandbox Code Playgroud)^ symbol: method toArrayList() location: variable nativeArray of type
ReadableNativeArray /Users/dobre/Desktop/projects//node_modules/react-native-admob/android/src/main/java/com/sbugert/rnadmob/RNAdMobBannerViewManager.java:223:
错误:找不到符号ArrayList list = nativeArray.toArrayList(); …
react-native-cli: 2.0.1
react-native: 0.53.3
ios 11.3.0 - 11.4.1
Run Code Online (Sandbox Code Playgroud)
Crashed: WebThread
0 JavaScriptCore 0x18a929464 JSC::JSLock::DropAllLocks::DropAllLocks(JSC::VM&) + 176
1 JavaScriptCore 0x18a929438 JSC::JSLock::DropAllLocks::DropAllLocks(JSC::VM&) + 132
2 WebCore 0x18b671cec SendDelegateMessage(NSInvocation*) + 360
3 WebKitLegacy 0x18cd96c68 CallDelegate(void (*)(), WebView*, objc_object*, objc_selector*, objc_object*, objc_object*, objc_object*) + 144
4 WebKitLegacy 0x18cd0a8d0 WebFrameLoaderClient::dispatchDidFailLoading(WebCore::DocumentLoader*, unsigned long, WebCore::ResourceError const&) + 276
5 WebCore 0x18b6a0df0 WebCore::ResourceLoadNotifier::didFailToLoad(WebCore::ResourceLoader*, WebCore::ResourceError const&) + 128
6 WebCore 0x18b6a08a8 WebCore::ResourceLoader::cancel(WebCore::ResourceError const&) + 464
7 WebCore 0x18b6a0634 WebCore::ResourceLoader::cancel() + 64
8 WebCore 0x18c5aa474 WebCore::CachedResource::removeClient(WebCore::CachedResourceClient&) + 264
9 WebCore …
Run Code Online (Sandbox Code Playgroud) 反应原生0.57集成RN Webview或 react-native-webview@2.4.0
在模拟器上,所有同级都被渲染(文本组件1-3)。在真实设备上,Webview与以前的同级重叠,并且不被渲染。
import React, { Component } from 'react';
import { ScrollView, View, WebView, Text } from 'react-native';
export default class MyWeb extends Component {
render() {
return (
<ScrollView contentContainerStyle={{ backgroundColor: 'pink', flexDirection: 'column', alignItems: 'center', justifyContent: 'center' }}>
<View style={{backgroundColor: 'yellow', margin: 5, height: 60, width: 300, alignItems: 'center', justifyContent: 'center' }}>
<Text>TEXT COMPONENT 1</Text>
</View>
<View style={{backgroundColor: 'yellow', height: 60, width: 300, alignItems: 'center', justifyContent: 'center' }}>
<Text>TEXT COMPONENT 2</Text>
</View>
<View style={{flex: 1}}>
<WebView …
Run Code Online (Sandbox Code Playgroud) 我找不到一种方法让 iOS RN 地图从缩放级别 0 开始或缩小到 0。
const allowScaling = false;
const region = {
latitude: 0,
longitude: 0,
latitudeDelta: 170,
longitudeDelta: 180,
};
return (
<View
style={{
position: 'relative',
width: '100%',
height: '100%',
overflow: 'hidden',
}}
>
<MapView
ref={this.setRef}
onPress={this.onPress}
onLongPress={this.onLongPress}
style={{ width: '100%', height: '100%' }}
zoomControlEnabled
provider={Platform.OS === 'ios' ? 'google' : 'osmdroid'}
moveOnMarkerPress={false}
customMapStyle={[
{
stylers: [
{
visibility: 'off',
},
],
},
]}
rotateEnabled={false}
scrollEnabled={allowScaling}
pitchEnabled={allowScaling}
zoomTapEnabled={allowScaling}
zoomEnabled={allowScaling}
cacheEnabled={false}
initialRegion={region}
onRegionChangeComplete={this.onRegionChange}
maxZoomLevel={Platform.OS === 'ios' ? …
Run Code Online (Sandbox Code Playgroud)