Bonjour,
Voila je rencontre un petit problème avec mon code.
Ce que je fais
Décrivez ici votre code ou ce que vous cherchez à faire
identification pour l'aacces a une application
import React from 'react';
import { View,Text, Image, TextInput, Button,Alert,StyleSheet } from 'react-native';
import styles from '../StylesPersos/Styles-Login';
import { StackNavigator } from 'react-navigation';
import Accueil from '../Pages/Accueil'
class TestSimple extends React.Component {
constructor (props) {
super(props)
this.componentDidMount = this.componentDidMount.bind(this)
this.state = {
isLoading: true,
result: '',
Nom: '',
Prenom: '',
report: null
}
}
getLogin(value) {
this.setState({
Login:value
});
}
getPassword(value) {
this.setState({
password:value
});
}
componentDidMount() {
var Param1 = 'Login=';
var Param2 = 'Mdp=';
var Saisie1 = "Alain";
var Saisie2 = "toto";
var Url = 'https://www.dudule.fr/Login.php?'+Param1+Saisie1+'&'+Param2+Saisie2;
fetch(Url)
.then((response) => response.json())
.then((responseJson) => {
console.log(responseJson)
this.setState({
result: responseJson.result,
Nom: responseJson.Nom,
Prenom: responseJson.Prenom
});
})
.catch((error) => {
console.error(error);
})
if(this.state.result == '0') {
Alert.alert('saisie erronée');
} else {
Alert.alert('salut '+this.state.Nom);
}
}
render() {
return (
<View style={styles.container}>
<View style={{}}>
<View style = {{marginTop: 15}}>
<TextInput style={styles.formInput}
placeholder = 'Login'
onChangeText={(value) => {this.getLogin(value)}}
underlineColorAndroid = "transparent"
/>
</View>
<View style = {{marginTop: 15}}>
<TextInput style={styles.formInput}
placeholder = 'password' secureTextEntry={true}
onChangeText={(value) => {this.getPassword(value)}}
underlineColorAndroid = "transparent"
/>
</View>
<View style = {{marginTop: 15}}>
<Button onPress={() => {this.componentDidMount()}}
title="Valider"
color="#841584"
accessibilityLabel="Learn more"
/>
</View>
</View>
</View>
);
}
}
export default StackNavigator({
TestSimple: { screen: TestSimple },
Accueil: { screen: Accueil },
})
Entourez votre code pour bien le mettre en forme
Ce que je veux
Le fonctionnement actuel est correct, mais je souhaite envoyer a 'componentDidMount', le résultat des 2 saisies Login et password.
Afin de remplacer Saisie1 et Saisie2
Ce que j'obtiens
Décrivez ici vos erreurs ou ce que vous obtenez à la place de ce que vous attendez :(
Pas d'erreurs mais rendre dynamique ce code.