setTimeout() not waiting in React Native

Gracias anticipadamente,

I´m trying to execute this function only after 15 seconds but it excecutes right away.

Estoy tratando de ejecutar la funcion setTimeout despue de 15 segundos en react native, pero esta se ejecuta ni bien comienza la aplicación.

Now, this component is being mounted around 8 times once the user logs into the application.

Ahora, el componente esta siendo ejecutado 8 veces una vez que se logea el usuario al aplicativo.

I got isFocused function to clear the timeout if it’s being focused, that fixes the times that is executing the function but not the problem of it actually waiting the 15 seconds.

Usé la función isFocused para limpiar el timeout si es que este componente esta siendo enfocado, esto arregla el problema de la multiple ejecución sonbre el mismo componente, pero no el problema que tengo de no esperar los 15 segundo qe especifique.

The goal is for the set timeout to actually wait the 15 seconds I specified if it gets cleared before that then nothing should happen and the application just continues normally.

El objetivo es lograr que el setTimeout realmente espere los 15 segundos, si es que la función se limpia con cleartimeout antes de eso no hay problema porque nada debería pasar. Solo en el evento de que se demoré mas de 15 segundos esto debería aparecer.

Here is the code:

Aquí está el código:

 constructor(props) {     super(props);     this.counter = 0;     this.timeout = null;  } componentDidMount(){     console.log('FIRST WHAT ARE THESE PROOPS', this.props)     this.timeout = setTimeout(this.waiting, 15000); } shouldComponentUpdate(){     if (!this.props.isFocused) {         clearTimeout(this.timeout);         this.timeout = null;     }     return true; } componentWillUnmount() {     clearTimeout(this.timeout);     this.timeout = null; } waiting = () => {     Alert.alert(         'Oops',         'An error ocurred while loading',         [             {                 text: 'OK', onPress: () => {                     console.log('HEY I CAME IN HERE')                     this.props.screen();                     this.props.navigation.goBack();                 }             }         ],         { cancelable: false }     ) } 

El mismo código pero en imagen, the same code but in an image

Posição do label no Picker do React Native

Estou utilizando o componente Picker do React Native e ta funcionando, listando, selecionando e tal, só que nn consigo estilizar bem ele, consegui colocar borda, arrumar o tamanho porem o texto que fica dentro dele eu nn consegui mexer, nem no tamanho da fonte e nem a posição que ele vai ficar la dentro, tentei colocar as propriedades flexDirection: 'row', alignItems: 'center', justifyContent: 'center' no style de uma View que fica sobre o Picker, no style do Picker e na propriedade itemStyle do Picker e nenhum destes funcionou, em todos o texto fica na esquerda, nn colado, mas fica pra esquerda e eu queria centralizar ele. Alguem pode me ajudar?

Código:

            <View style={HorariosCommandStyles.containerPickerServicos}>                 <Picker itemStyle={{ paddingLeft: 50, fontSize: 35 }} style={{ width: '90%', height: '100%' }}>                     {this.state.servicos.map(s => <Picker.Item label={s.servico.nome} value={s.servico.id} key={s.id} />)}                 </Picker>             </View>

react native renderizado condicional de tabnav

Estoy haciendo una app con react-native, cuando el user se registra se le asigna un rol que cuando la app llega a la home, el tabnavbottom cambia.

Ahora mismo le estoy pasando al componente que renderiza el tabnavbottom por props, pero se me queda atascado en el estado por defecto.

os pongo el código.

import React, {Component} from 'react'; import {Platform, StyleSheet, Text, View} from 'react-native'; import Router from './src/routes/router';  import {Provider} from 'react-redux' import { createStore } from 'redux'; import devToolsEnhancer from 'remote-redux-devtools'; import reducers from './src/redux/reducers'  const store = createStore(reducers, devToolsEnhancer());  class App extends Component { 	constructor(props){ 		super(props)  		this.state = { 			role: store.getState().user.role 		} 	}   	componentWillReceiveProps(nextProps) { 		console.log('nextProps===>', nextProps) 		this.setState({role: nextProps.state.user.role }); 	}   	shouldComponentUpdate(nextProps) { 		console.log('pues entro') 		return true 	} 	render() { 		return ( 			<Provider store={store}> 				<Router role={this.state.role}/> 			</Provider> 		) 	} }  export default App

import React, {Component} from 'react'; import {Platform, StyleSheet, Text, View} from 'react-native'; import Icon from 'react-native-vector-icons/FontAwesome';  import UserPaths from './UserPaths'; import TransporterPaths from './TransporterPaths';   class Router extends Component {   	renderByRole(){ 		console.log('KALIMA', this.props.role) 		if(this.props.role === 'user'){ 			return( 				<UserPaths /> 			) 		}else{ 			return ( 				<TransporterPaths /> 			) 		} 	}  	render() { 		return ( 			<View style={{flex:1}}> 				{this.renderByRole()} 			</View> 		) 	} }  export default Router

import React, {Component} from 'react'; import {Platform, StyleSheet, Text, View} from 'react-native'; import Icon from 'react-native-vector-icons/FontAwesome'; import { createBottomTabNavigator, createStackNavigator, tabBarIcon } from 'react-navigation';  import I18n from '../i18n/i18n'  //screens common import WelcomeScreen from '../screens/WelcomeScreen'; import LoginScreen from '../screens/LoginScreen'; import SignUpScreen from '../screens/SignUpScreen'; import HomeScreen from '../screens/HomeScreen'; import ProfileScreen from '../screens/ProfileScreen'; //Screens transporter import TransporterShowOrderScreen from '../screens/TransporterShowOrderScreen'; import TransporterOrderCard from '../components/transporter/TransporterOrderCard'; import TransporterOrdinaryListScreen from '../screens/TransporterOrdinaryListScreen';  class TransporterPaths extends Component { 	render(){ 		const TransporterNavigator = createStackNavigator({ 			welcome: { 				screen: WelcomeScreen, 				navigationOptions: { 					header: null 				} 			}, 			login: { 				screen: LoginScreen, 				navigationOptions: { 					header: null 				} 			}, 			signUp: { 				screen: SignUpScreen, 				navigationOptions: { 					header: null 				} 			}, 			transporterShowOrderScreen: { 				screen: TransporterShowOrderScreen, 				navigationOptions: { 					header: null 				} 			}, 			trasnsporterOrderCard: { 				screen: TransporterOrderCard, 				navigationOptions: { 					header: null 				} 			}, 			main: { 				screen: createBottomTabNavigator({ 					userHome: { 						screen: HomeScreen, 						navigationOptions: { 							tabBarLabel: I18n.t('nav.nowSends'), 							header: null, 							tabBarIcon: ({tintColor}) =>(<Icon name="home" size={20} color={tintColor} />) 						} 					}, 					ordinaryList: { 						screen: TransporterOrdinaryListScreen, 						navigationOptions: { 							tabBarLabel: I18n.t('nav.sends'), 							header: null, 							tabBarIcon: ({ tintColor}) => (<Icon name="cubes" size={20}  color={tintColor}/>) 						} 					}, 					userProfile: { 						screen: ProfileScreen, 						navigationOptions: { 							tabBarLabel: I18n.t('nav.profile'), 							header: null, 							tabBarIcon: ({ tintColor}) => (<Icon name="user-circle" size={20}  color={tintColor}/>) 						} 					}, 				},{ 					tabBarOptions: { 						activeTintColor: '#521168', 						inactiveTintColor: '#fff', 						labelStyle: { 							fontSize: 11, 							fontWeight: 'bold' 						}, 					style: { 						backgroundColor: '#d3560e', 						height: (Platform.OS === 'ios') ? 48 : 50 					} 				} 			}) 		}, 		},{ 			navigationOptions: { 				tabBarVisible:  false, 				header: null, 			} 		}) 		return(<TransporterNavigator />) 	} }  export default TransporterPaths;

import React, {Component} from 'react'; import {Platform, StyleSheet, Text, View} from 'react-native'; import Icon from 'react-native-vector-icons/FontAwesome'; import { createBottomTabNavigator, createStackNavigator, tabBarIcon } from 'react-navigation';  //screens common import WelcomeScreen from '../screens/WelcomeScreen'; import LoginScreen from '../screens/LoginScreen'; import SignUpScreen from '../screens/SignUpScreen'; import HomeScreen from '../screens/HomeScreen'; import ProfileScreen from '../screens/ProfileScreen'; //screens user import UserNewOrderScreen from '../screens/UserNewOrderScreen'; import UserOrderListScreen from '../screens/UserOrderListScreen'; import UserOrderedListScreen from '../screens/UserOrderedListScreen'; import UserTracingScreen from '../screens/UserTracingScreen'; import UserRatingScreen from '../screens/UserRatingScreen';   class UserPaths extends Component { 	render(){  		const UserNavigator = createStackNavigator({ 			welcome: { 				screen: WelcomeScreen, 				navigationOptions: { 					header: null 				} 			}, 			login: { 				screen: LoginScreen, 				navigationOptions: { 					header: null 				} 			}, 			signUp: { 				screen: SignUpScreen, 				navigationOptions: { 					header: null 				} 			}, 			rating: { 				screen: UserRatingScreen, 				navigationOptions: { 					header: null 				} 			}, 			main: { 				screen: createBottomTabNavigator({ 					userHome: { 						screen: HomeScreen, 						navigationOptions: { 							tabBarLabel: 'Home', 							header: null, 							tabBarIcon: ({tintColor}) =>(<Icon name="home" size={20} color={tintColor} />) 						} 					}, 					userNewOrder: { 						screen: UserNewOrderScreen, 						navigationOptions: { 							tabBarLabel: 'N. Envio', 							header: null, 							tabBarIcon: ({tintColor}) => (<Icon name="plus-square" size={20}  color={tintColor}/>) 						} 					}, 					userOrderList: { 						screen: UserOrderListScreen, 						navigationOptions: { 							tabBarLabel: 'Presupuestos', 							header: null, 							tabBarIcon: ({tintColor}) => (<Icon name="inbox" size={20}  color={tintColor}/>) 						} 					}, 					userOrderedList: { 						screen: UserOrderedListScreen, 						navigationOptions: { 							tabBarLabel: 'Histórico', 							header: null, 							tabBarIcon: ({tintColor}) => (<Icon name="list" size={20} color={tintColor} />) 						} 					}, 					userProfile: { 						screen: ProfileScreen, 						navigationOptions: { 							tabBarLabel: 'Perfil', 							header: null, 							tabBarIcon: ({ tintColor}) => (<Icon name="user-circle" size={20}  color={tintColor}/>), 							style:{backgroundColor:'red'} 						} 					} 				},{ 					tabBarOptions: { 						activeTintColor: '#521168', 						inactiveTintColor: '#fff', 						labelStyle: { 							fontSize: 11, 							fontWeight: 'bold' 						}, 						style: { 							backgroundColor: '#d3560e', 							height: (Platform.OS === 'ios') ? 48 : 50 						} 					} 				}) 			}, 		},{ 			navigationOptions: { 				tabBarVisible:  false, 				header: null, 			} 		}); 		return( 			<UserNavigator /> 		) 	} }  export default UserPaths;

Gracias

Native U.S. Writer Available

Hello DP clients, at this time I am searching and available to write some content for some people whether that would be on a long term basis or a short term basis.

I am able to write on a variety of different niches/topics. Some topics I do have a bit more experience with writing on compared to others. Just message me to ask me about writing on your niche. I'm looking to write articles of no more than 500+ words. They will be unique and checked for grammar errors, etc. before I send them to…

Native U.S. Writer Available

Native English Writer – Satisfaction Guaranteed! (Request your FREE sample!)

Hello Everyone,

I am a native speaker of English and no, I'm not throwing around the term "native English writer" like a lot of the other writers here on DP who clearly don't speak English as a first language.

I am looking for long-term writing work and I can assure you that you won't find many writers who will provide better quality at my price range.

I can write on most topics; just fill me in on which niche you want your articles on (including other specific…

Native English Writer – Satisfaction Guaranteed! (Request your FREE sample!)

Problemas com plugin Ionic Native Device Accounts

Estou tentando obter as contas cadastradas no dispositivo com o plugin device accounts do ionic, porém na promise não tem me retornado nada no console.

O meu código é :

  testeSemNative() {     DeviceAccounts.getPlugin().getEmail(      account => console.log('Account' + account),       error => console.error(error));      DeviceAccounts.getPlugin().get(      accounts => console.dir(accounts),       error => console.error(error));    }     testeComNative() {      this.deviceAccounts.get()        .then(accounts => console.log(accounts))        .catch(error => console.error(error));    } 

Pesquisei em alguns lugares, e tinha um tópico sugerindo para usar um outro modelo de código, portanto tentei realizar um teste utilizando o ionic native, e outro teste chamando diretamente o plugin, porém em ambos não consegui obter nenhum resultado

Although GNOME Shell integration extension is running, native host connector is not detected

On a fresh install of 18.10 I attempted to install CPU usage widget

https://extensions.gnome.org/extension/120/system-monitor/

on that link it errors showing :

Although GNOME Shell integration extension is running, native host connector is not detected

Prevent screenrecording on Expo React Native

I’m using Expo SDK 31.0.0

On Android, I can disable screen recording by setting the FLAG_SECURE flag. Is there a way to do the eqivalent in iOS?

https://github.com/hawkup/react-native-prevent-screenshot

https://github.com/ycswaves/react-native-screen-recorder

Seem to be solutions that work on an ejected app.

How can I achieve this using Expo? I do not want to eject the app.