我有一个平面列表,它可以渲染带有叠加层的图像等。
我创建了一个动画背景,它会随着图像加载而改变颜色(效果很好)。但一旦图像加载,我就很难让背景消失。我尝试使用 onLoad 但设置 this.state 适用于列表中的所有图像。另外,如果图像在加载之前是隐藏的,那就更好了。我更喜欢实时延迟加载,而不是在 ComponentWillMount 中预取它们。
有任何想法吗?
<Image
source={{uri: image}}
style={styles.cardImg}
onLoad={() => this.state.imageLoaded = true}
/>
{!this.state.imageLoaded && (
<Animated.View
style={[styles.cardBg, {
backgroundColor: this._animatedValue.interpolate({
inputRange: [0, 100],
outputRange: ['rgba(100,100,100, 0.3)', 'rgba(100,100,100,0.5)']
})
}]}
/>
)}
Run Code Online (Sandbox Code Playgroud)
更新
<FlatList
ref={(ref) => { this.FlatList = ref; }}
data={this.props.data}
keyExtractor={(item) => item._id}
renderItem={this._renderCard.bind(this)}
onEndThreshold={50}
onEndReached={this.props.loadMore}
ListFooterComponent={this._renderFooter}
showsVerticalScrollIndicator={false}
style={styles.list}
extraData={this.state}
refreshControl={<RefreshControl
refreshing={this.props.loading}
onRefresh={this.props.onRefresh}
/>}
/>
Run Code Online (Sandbox Code Playgroud)
更新2
理想情况下,我正在寻找类似的东西(代码不起作用):
<Image source={{uri: image}} style={styles.cardImg} onError={(e) => {card.item.media.error = true}}/>
Run Code Online (Sandbox Code Playgroud) 尝试获取货币文本(52 0000,00 USD),我希望股票的字体粗细与金额不同。我希望使用 adjustmentFontSizeToFit 使文本填充整个屏幕宽度。
当使用相同的 Text 和 fontWeight 时,它可以工作,但使用嵌套<Text>比例会缩小字体大小超出必要的范围?
你可以在这里尝试一下:
https://snack.expo.io/Hk1-K3RwG
import React, { Component } from 'react';
import { Text, View, StyleSheet } from 'react-native';
import { Constants } from 'expo';
export default class App extends Component {
render() {
return (
<View style={styles.container}>
<Text style={[styles.text, {fontWeight: '900'}]} adjustsFontSizeToFit numberOfLines={1}>
{'245,000.00'}{'\u00a0'}USD
</Text>
<Text style={styles.text} adjustsFontSizeToFit numberOfLines={1}>
<Text style={{ fontWeight: '900'}}>{'245,000.00'}</Text>
{'\u00a0'}
<Text style={{ fontWeight: '400'}}>USD</Text>
</Text>
</View>
);
}
}
const styles = StyleSheet.create({
container: …Run Code Online (Sandbox Code Playgroud)我想在App被杀死时在后台调用API并在AsyncStorage中设置数据。我使用了以下库,但不适合我。
我想在没有时间安排的情况下调用API。上面都使用了时间调度。
请帮我。
react-native react-native-ios uibackgroundmode ios-background-mode
您能帮助我们集成这些出色的工具吗?我们的 React Native iOS 项目已经使用 Crashlytics 几个月了,它在本机崩溃的情况下运行良好,但在JS 异常的情况下,它需要对反应本机日志进行一些自定义(这篇 Medium 文章帮助我们达到了详细的 JS 输出,如可能的)。最终我们没有得到我们想要的那么好的 JS 错误输出。
因此我们决定也集成 Sentry。它成功完成了,但似乎 Sentry超过了Crashlytics 捕获崩溃的速度:我们可以在 Sentry 仪表板中看到崩溃,但在 Crashlytics 仪表板中看不到。
我的问题是:是否可以针对本机崩溃和 JS 异常这两种情况集成 Crashlytics 和 Sentry ?
先感谢您。
UPD 06.03.2019 最后,我们只使用 Sentry,原因如下:
sentry crashlytics react-native react-native-ios react-native-sentry
我正在我的 React-Native 应用程序中使用react-native-fbsdk. 我不明白为什么“使用 facebook 应用程序登录”不起作用。当用户单击此按钮而不是在 Web 视图中输入其凭据时,LoginManager回调似乎永远不会被触发。
以下是发生的情况的视频:https://i.imgur.com/1XeJC1o.mp4
这个问题似乎可能是常见问题解答中的这个问题,但我相信我的AppDelegate.m文件Info.plist设置正确。
#import "AppDelegate.h"
#import <React/RCTBundleURLProvider.h>
#import <React/RCTRootView.h>
#import <SentryReactNative/RNSentry.h>
#import <GoogleMaps/GoogleMaps.h>
#import <react-native-branch/RNBranch.h>
#import <FBSDKCoreKit/FBSDKCoreKit.h>
#import <RNGoogleSignin/RNGoogleSignin.h>
#import <CodePush/CodePush.h>
#import <AppCenterReactNativeCrashes/AppCenterReactNativeCrashes.h>
#import <AppCenterReactNativeAnalytics/AppCenterReactNativeAnalytics.h>
#import <AppCenterReactNative/AppCenterReactNative.h>
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
[RNBranch initSessionWithLaunchOptions:launchOptions isReferrable:YES];
NSURL *jsCodeLocation;
[AppCenterReactNativeCrashes registerWithAutomaticProcessing]; // Initialize AppCenter crashes
[AppCenterReactNativeAnalytics registerWithInitiallyEnabled:true]; // Initialize AppCenter analytics
[AppCenterReactNative register]; // Initialize AppCenter
[GMSServices provideAPIKey:@"myAPiKey"];
[[FBSDKApplicationDelegate sharedInstance] application:application …Run Code Online (Sandbox Code Playgroud) 在阅读了大量 StackOverflow 解决方案后,我遇到了这个愚蠢的错误问题已经有几天了,但仍然没有修复。我正在将我的应用程序部署到 Apple Connect 测试飞行,并且 Fastlane 配置正常,并且可以顺利完成整个过程。它到达了要将应用程序上传到我们的团队测试飞行帐户的部分,并且此错误不断弹出。
尝试的解决方案:
我的图标在 Images.xcassets/AppIcon.appiconset
我知道以前有人问过这种问题,但它们与第三方库有关,我的与 requireNativeComponent
我已经React Native从本地iOS组件创建了一个组件
这是我的iOS代码
CanvasView 文件
class CanvasView: UIView {
var lines = [[CGPoint]]()
override init(frame: CGRect) {
super.init(frame:frame)
backgroundColor = #colorLiteral(red: 1, green: 1, blue: 1, alpha: 0)
}
required init?(coder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
override func draw(_ rect: CGRect) {
super.draw(rect)
guard let context = UIGraphicsGetCurrentContext() else {
return
}
context.setStrokeColor(#colorLiteral(red: 0.9529411793, green: 0.6862745285, blue: 0.1333333403, alpha: 1))
context.setLineWidth(10)
context.setLineCap(.butt)
lines.forEach { (line) in
for(i,p) in line.enumerated() …Run Code Online (Sandbox Code Playgroud) react-native react-native-android react-native-ios react-native-native-module
所以我试图从 firebase 和 react-native-push-notifications 接收推送通知。react-native-push-notifications on android 其工作完美。
我的问题仅在 IOS 上。我已经按照push-notification-ios安装没有结果。
包.json :
{
"name": "app",
"version": "0.0.1",
"private": true,
"scripts": {
"android": "react-native run-android",
"ios": "react-native run-ios",
"start": "react-native start",
"test": "jest",
"lint": "eslint ."
},
"dependencies": {
"@react-native-community/push-notification-ios": "^1.4.0",
"@react-native-community/toolbar-android": "^0.1.0-rc.2",
"@react-native-firebase/app": "^8.3.1",
"@react-native-firebase/messaging": "^7.7.2",
"axios": "^0.19.2",
"react": "16.13.1",
"react-native": "0.63.2",
"react-native-document-picker": "^3.5.4",
"react-native-image-crop-picker": "^0.32.2",
"react-native-image-picker": "2.3.1",
"react-native-mail": "^5.0.1",
"react-native-permissions": "^2.1.5",
"react-native-push-notification": "^5.0.1",
"react-native-restart": "^0.0.17",
"react-native-vector-icons": "^7.0.0",
"react-native-webview": "^10.4.0"
},
"devDependencies": {
"@babel/core": "^7.11.1",
"@babel/runtime": …Run Code Online (Sandbox Code Playgroud) push-notification apple-push-notifications ios firebase-cloud-messaging react-native-ios
我遇到了这个错误 [Unhandled promise rejection: Error: Native splash screen is already hidden. Call this method before rendering any view.]
不知道为什么会发生这种情况,但我只想在继续之前解决这个问题。
我的 App.js:
in App (created by ExpoRoot)
in ExpoRoot (at renderApplication.js:45)
in RCTView (at View.js:34)
in View (at AppContainer.js:106)
in DevAppContainer (at AppContainer.js:121)
in RCTView (at View.js:34)
in View (at AppContainer.js:132)
in AppContainer (at renderApplication.js:39)
Run Code Online (Sandbox Code Playgroud)
这是我的 App.js
in App (created by ExpoRoot)
in ExpoRoot (at renderApplication.js:45)
in RCTView (at View.js:34)
in View (at AppContainer.js:106)
in DevAppContainer (at AppContainer.js:121)
in RCTView (at …Run Code Online (Sandbox Code Playgroud) react-native-ios ×10
react-native ×9
reactjs ×3
ios ×2
crashlytics ×1
expo ×1
javascript ×1
sentry ×1
xcode ×1