react-native-android

In React Native how to Store values in session?

末鹿安然 提交于 2019-12-03 16:25:26
In React Native how to Store values in session ? I need to store login details (Username , Password) in session . Could you Please Give any ideas. Use AsyncStorage . Example: For save: AsyncStorage.multiSet([ ["email", userInfo.email], ["password", userInfo.password] ]) For Delete: let keys = ['email', 'password']; AsyncStorage.multiRemove(keys, (err) => { console.log('Local storage user info removed!'); }); For Get: AsyncStorage.multiGet(['email', 'password']).then((data) => { let email = data[0][1]; let password = data[1][1]; if (email !== null) //Your logic }); PDTA: as Raheel mentions

How to stop the Android Hardware Back Button from functioning in react-navigation for react-native?

荒凉一梦 提交于 2019-12-03 16:03:56
I am developing a trivia game, I am using react-navigation to handle navigation, I have 3 components, (newGame, Questions, Results ) I don't want the user to go back to the questions from the results page if the no. of questions has been exhausted, however, pressing the back button ( Android Hardware ) is taking him back to the questions. I then tried to handle the hardware back button like so: componentWillMount() { this.props.gameState(true); BackHandler.addEventListener('hardwareBackPress', () => { if (this.props.gamePlaying) { // Currently set to true. I will set it to false again on

How can we center title of react-navigation header?

a 夏天 提交于 2019-12-03 15:46:54
问题 React-navigation docs are still young, and reading through the issues is not working quite much for me (changes on each version) does anyone have a working method to center title in Android using react-navigation in React Native? 回答1: Use headerTitleStyle: static navigationOptions = { headerTitleStyle: { alignSelf: 'center' }, title: 'Center Title', } Modified 2019/03/12: In year of 2018, after react-navigation v2 release (7 Apr 2018), for some reason alignSelf was not working anymore. Here

Is React Native's LayoutAnimation supported on Android?

自古美人都是妖i 提交于 2019-12-03 15:14:04
问题 I do not see anything in the documentation referring to lack of support for Android. I'm using a simple preset animation: LayoutAnimation.configureNext(LayoutAnimation.Presets.spring); It works in iOS, but in Android it makes the transition without any spring animation. 回答1: As per this for Android support you have to add these lines: import { UIManager, LayoutAnimation } from 'react-native'; //.. UIManager.setLayoutAnimationEnabledExperimental && UIManager

React Native Android Release Build Failing - Gradle

两盒软妹~` 提交于 2019-12-03 12:40:30
问题 I've got a rather complicated project some of which is older code from the past year or so which in React Native time is forever. The regular debug build is working fine but the release build has errors. I've cobbled together answers from other places to make it as far as I have but I don't know how to get past this last bit. I keep getting a bundling error where aapt will fail because it doesn't bundle the resources properly. Example of error code: > Task :app:bundleReleaseJsAndAssets

React-Native FlatList performance problems with large list

北慕城南 提交于 2019-12-03 12:39:27
My code gets Json data to an array lists the data using a FlatList . It looks like a phonebook photo and text in a row. Here is My code: renderItem = ({ item }) => ( <ListItem title={item.username} avatar={{ uri: item.photo }} /> ) render() { console.log(this.state.myData); return ( <View style={styles.container}> <FlatList data={this.state.myData} renderItem={this.renderItem} /> </View> ); } Its works and I get the output, but the performance is slow. Rendering takes approximately 10 seconds which is annoying to the user. What should I do to make it faster? Here are some improvements you can

Element overflow hidden in React-Native Android

时光毁灭记忆、已成空白 提交于 2019-12-03 11:57:28
I have an app here where I need to put the logo in the navbar. That need to overflow the scene layout. Work well in Ios with no problem but in android seem like he not working. I put the code at the bottom of the images. As you can see I use EStyleSheet so that let me use %. IOS Android import React from 'react'; import { Scene, Router } from 'react-native-router-flux'; import EStyleSheet from 'react-native-extended-stylesheet'; import { View, Platform } from 'react-native'; import { SmallLogo } from './components'; import { checkColor } from './helpers'; import { HomeScreen, ImagePickerScreen

How can we center title of react-navigation header?

被刻印的时光 ゝ 提交于 2019-12-03 11:27:40
React-navigation docs are still young, and reading through the issues is not working quite much for me (changes on each version) does anyone have a working method to center title in Android using react-navigation in React Native? Val Use headerTitleStyle : static navigationOptions = { headerTitleStyle: { alignSelf: 'center' }, title: 'Center Title', } Modified 2019/03/12: In year of 2018, after react-navigation v2 release (7 Apr 2018), for some reason alignSelf was not working anymore. Here it is the new working way, using headerLayoutPreset . from @HasanSH: const HomeActivity_StackNavigator =

Cannot run adb shell “date `date +%m%d%H%M%Y.%S`”

孤街浪徒 提交于 2019-12-03 10:51:11
I have a warning when running React Native on an Android device: Debugger and device times had drifted by more than 60s. Please correct this by running adb shell "date `date +%m%d%H%M%Y.%S`" on your debugger machine But when I run the command as suggested above, I get and operation not permitted error: date: cannot set date: Operation not permitted I already tried with sudo, still got same result: sudo adb shell "date `date +%m%d%H%M%Y.%S`" atinder Inside the emulator goto Settings > Date & Time Deselect Automatic timezone. Adjust your timezone manually. Deselect automatic date & time and set

Refresh previous screen on goBack()

人盡茶涼 提交于 2019-12-03 08:08:11
问题 I am new to React Native. How can we refresh/reload previous screen when returning to it by calling goBack() ? Lets say we have 3 screens A, B, C: A -> B -> C When we run goBack() from screen C it goes back to screen B but with old state/data. How can we refresh it? The constructor doesn't get called 2nd time. 回答1: Yes, constructor is called only for the first time and you can't call it twice. First : But you can separate the data getter/setter from the constructor and put it in a function,