所以我有一个带有活动的应用程序。该应用程序会在开始时检查 Internet 连接。如果没有 Internet 连接,它将显示一个带有刷新页面按钮的屏幕。问题是我的 API 调用 (Axios) 位于componentDidMount()第一次渲染后仅调用一次的位置。有什么办法可以重新加载页面,以便它调用componentDidMount再次?
我的意思是完全刷新。顺便说一句,我正在使用 EXPO。任何帮助表示赞赏。抱歉,没有示例,如果可能的话,我只是想了解一下
我们的 react-native 应用程序似乎有时会在 Android 上崩溃,PRD 实例缺少“libjsc.so”错误,而 Firebase 中的唯一细节是:
Crashed: Thread: SIGSEGV 0x0000000000000010
at (Missing)()
at (Missing)()
at (Missing)()
Run Code Online (Sandbox Code Playgroud)
我每天会在数百个日志中看到大约 6-10 次 Firebase 日志。
我们无法重现该问题。根据 Firebase 日志,崩溃似乎不会发生在特定屏幕上,但最常见于应用启动到登录屏幕后。当 RN 版本为 0.59.9 时,之前没有看到此崩溃日志。我最近将我们的应用程序升级到 RN 0.61.5,这似乎是一个趋势崩溃,但通过我的谷歌搜索,我没有找到任何与此崩溃日志接近的内容。
我尝试了什么?我认为这可能与 android 64 位支持有关,因此我在 app/build.gradle 中添加了以下内容,但即使在发布此修复程序后,我们仍然看到相同的崩溃。
...
pickFirst 'lib/armeabi-v7a/libjsc.so'
pickFirst 'lib/x86/libjsc.so'
pickFirst 'lib/arm64-v8a/libjsc.so'
pickFirst 'lib/x86_64/libjsc.so'
}
Run Code Online (Sandbox Code Playgroud)
希望这里的人可以帮助/提供他们对这个问题的想法。谢谢!
我一直在编写一个包含BottomSheetBehavior的原生android模块.
一个非常简单的BottomSheetBehavior可以像这样实现 https://gist.github.com/cesardeazevedo/a4dc4ed12df33fe1877fc6cea42475ae
我面对的第一件事,整个页面必须是CoordinatorLayout的子节点和底部的BottomSheetBehavior.
所以我不得不写2个原生模块,<CoordinatorLayout />和<BottomSheetBehavior />.
这是bottomSheetBehavior包装器.
BottomSheetBehaviorManager.java
public class BottomSheetBehaviorManager extends ViewGroupManager<BottomSheetBehaviorView> {
@Override
public BottomSheetBehaviorView createViewInstance(ThemedReactContext context) {
return new BottomSheetBehaviorView(context);
}
}
Run Code Online (Sandbox Code Playgroud)
BottomSheetBehaviorView.java
public class BottomSheetBehaviorView extends RelativeLayout {
public BottomSheetBehaviorView(Context context) {
super(context);
int width = ViewGroup.LayoutParams.WRAP_CONTENT;
int height = ViewGroup.LayoutParams.WRAP_CONTENT;
// int height = 1000; // fixed a height works, it only slide up half of the screen
CoordinatorLayout.LayoutParams params = new CoordinatorLayout.LayoutParams(width, height);
params.setBehavior(new BottomSheetBehavior());
this.setLayoutParams(params);
BottomSheetBehavior<BottomSheetBehaviorView> …Run Code Online (Sandbox Code Playgroud) 我正在尝试在React Native中构建一个发行版.apk文件但没有成功.我按照这里的所有说明操作,但gradlew assembleRelease在/ my-project/android路径中运行后总是得到相同的结果:
:app:validateSigningRelease FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:validateSigningRelease'.
> Keystore file not set for signing config release
Run Code Online (Sandbox Code Playgroud)
我正在使用Windows 10,我怀疑它是编辑文件〜/ .gradle/gradle.properties的东西
从我的理解〜是c:\ Users\User我甚至得到了ac:\ Users\User.gradle文件夹内置.
我正在使用React Native 0.46编写原生Android模块,但我无法从模块中获取当前活动实例.
我有一个扩展ReactContextBaseJavaModule的类,它包含一个内置的getCurrentActivity()方法.但是,每次调用此方法时,我都会得到一个null.
我想这是因为我在我的模块构造函数中调用它,它在Android应用程序的开头执行,可能在Activity实例化之前?
如果你们知道从模块中访问当前Activity实例的干净方法(如果可能的话,不必在某个时刻存储一个Activity实例并传递它),我会很高兴的!
我最近开始反应原生和跟随教程指南有2个选项一个是通过"create-react-native-app myproject"创建项目,另一个是"react-native init myproject".
第一个(create-react-native-app)只生成app.js而另一个生成index.android.js和index.ios.js ..
我知道他们在做同样的工作,但这里真正的不同之处是什么?我应该选择哪一个开始,哪一个更有用?
我已经把android后退按钮退出我的主屏幕中的反应本机应用程序中的应用程序功能.但是当我在其他屏幕上按下android后退按钮时,它也会被调用.
componentDidMount() {
if (Platform.OS == "android") {
BackHandler.addEventListener('hardwareBackPress', this.handleBackButton);
}
this._setupGoogleSignin();
this._getUserDetails();
const { navigate } = this.props.navigation;
console.log("object url is", this.state.postsArray[0].url);
}
handleBackButton = () => {
Alert.alert(
'Exit App',
'Exiting the application?', [{
text: 'Cancel',
onPress: () => console.log('Cancel Pressed'),
style: 'cancel'
}, {
text: 'OK',
onPress: () => BackHandler.exitApp()
}, ], {
cancelable: false
}
)
return true;
}
componentWillUnmount() {
BackHandler.removeEventListener('hardwareBackPress', this.handleBackButton);
}
Run Code Online (Sandbox Code Playgroud) 嗨,我正在开发基于FlatList的示例应用程序,这是我的代码.实际上我显示了整个记录,比如我有50条记录到我的账户.但现在我显示了整整50条记录.Bur我需要在添加10条记录后显示10.但我不知道添加到FlatList.
这是我的代码:
<FlatList
data={this.state.profiles}
renderItem={({ item, index }) => this.renderCard(item, index)}
keyExtractor={item => item.id}
ItemSeparatorComponent={() => <Divider style={{ marginTop: 5, marginLeft: width * 0.2 + 20 }} parentStyle={{ backgroundColor: globalStyles.BG_COLOR, alignItems: 'baseline' }} />}
/>
renderCard (profile, index) {
console.log('rendercard', profile);
//
return (
<View key={profile.id}>
<ProfileCard
profile={profile}
style={styles.card}
onPress={() => this.props.screenProps.rootNavigation.navigate('Profile', { profile: this.state.profile, id: profile.id })}
// onPress={() => alert('PROFILE')}
onAddClick={() => this.setState({ connectionPageVisible: true, cardProfile: profile })}
connectedIds={(this.props.screenProps && this.props.screenProps.connectedIds) || this.props.connectedIds}
/>
</View>
);
}
Run Code Online (Sandbox Code Playgroud)
请告诉我使用活动指标加载更多记录.提前致谢
react-native react-native-android react-native-ios react-native-flatlist
是否可以将prop添加nativeID到如下视图中:
<View nativeID="viewId">...</View>
然后使用该id在我的原生android和iOS代码中查找视图,以便我可以在其上应用一些本机方法.如果它是一个例子将不胜感激.
我正在尝试在视图底部添加阴影,但是我不打算在Android上这样做。有了elevation它,阴影也在顶部。有没有办法像在iOS上那样呢?
这是我的代码:
export function makeElevation(elevation) {
const iosShadowElevation = {
shadowOpacity: 0.0015 * elevation + 0.18,
shadowRadius: 0.5 * elevation,
shadowOffset: {
height: 0.6 * elevation,
},
};
const androidShadowElevation = {
elevation,
};
return Platform.OS === 'ios' ? iosShadowElevation : androidShadowElevation;
Run Code Online (Sandbox Code Playgroud)
}
左:iOS(预期)
右:Android
android shadow android-styles react-native react-native-android