संपादित करें: ऐसा लगता है कि अगर मैं "this.setState ({log_in: true})" पंक्ति पर टिप्पणी करता हूं, "लाइन 63, मुझे त्रुटि नहीं मिली है। मेरा अनुमान है कि जिस तरह से मैं लॉग इन फ़ंक्शन में प्रदर्शित सामग्री को बदलने की कोशिश कर रहा हूं, उस पर आधारित है कि उपयोगकर्ता लॉग इन है या नहीं, इस त्रुटि का कारण क्या है। कोई विचार?त्रुटि: "अमान्य डेटा संदेश - सभी लंबाई होना चाहिए: 8" - पिकरआईओएस
मैं प्रतिक्रिया मूल के कुछ मूलभूत सिद्धांतों को समझने में कुछ मामूली प्रगति कर रहा हूं, मुझे लगता है। यद्यपि मेरा कोड सुंदर नहीं हो सकता है, जब तक कि कुछ हालिया जोड़ों तक यह काम नहीं करता। मैं आईओएस सिम्युलेटर में एक त्रुटि संदेश प्राप्त कर रहा हूं जो "अमान्य डेटा संदेश" पढ़ता है - सभी लंबाई होना चाहिए: 8 "। दुर्भाग्य से मुझे कोई विनिर्देश नहीं दे रहा है जो मैं समझता हूं, जैसे कि linenumbers।
अगर मैं एक रिपोस्ट है, तो मैं ईमानदारी से क्षमा चाहता हूं, मैं इस त्रुटि का हल ढूंढने के लिए Google और stackoverflow पर पागल दिख रहा हूं लेकिन मेरी खोजों में असफल रहा है।
मैंने यूआरएल को सेंसर किया है जिसे मैंने लाने में उपयोग किया है क्योंकि यह बहुत शुरुआती चरणों में कंपनी के भीतर परीक्षण के लिए एक एड्रेस है, लेकिन मैं 99,99% निश्चित हूं कि समस्या नहीं है।
मेरे index.ios.js:
import React, { Component } from 'react';
import {
AppRegistry,
StyleSheet,
Text,
View,
Button,
Alert,
TextInput,
TouchableHighlight,
Image,
AlertIOS,
PickerIOS,
} from 'react-native';
var REASONS = {
sick: {
name: "sjuk"
},
vacation: {
name: "semester"
},
child_care: {
name: "vård av barn"
},
parenting: {
name: "föräldraledig"
},
general: {
name: "övrigt"
},
};
export default class mbab_franvaro extends Component {
constructor(props) {
super(props);
this.state = {username: '', password: '', logged_in: false, reason: 'sjuk'};
}
logout(){
this.setState({logged_in: false});
this.username = ""; this.password = "";
}
login(){
if(this.state.username == "" || this.state.password == ""){
AlertIOS.alert("Fel", "Vänligen fyll i alla fält.");
}
else{
fetch("MY_PRIVATAE_COMPANY_URL", {
method: "POST",
headers: {
'Accept': 'application/x-www-form-urlencoded',
'Content-Type': 'application/x-www-form-urlencoded',
},
body: "username=" + this.state.username + "&password=" + this.state.password,
})
.then((response) => response.json())
.then((response) => {
if(JSON.stringify(response.body).replace(new RegExp('"', 'g'), '').match("Inloggad")){
this.username = this.state.username; this.password = this.state.password;
this.setState({logged_in: true});
//AlertIOS.alert("Hej!", "Välkommen " + this.username + "!");
}
else{
AlertIOS.alert(
"Fel",
JSON.stringify(response.body).replace(new RegExp('"', 'g'), '')
);
}
})
.catch((error) => {
AlertIOS.alert("error", error);
})
.done();
}
}
render(){
if(this.state.logged_in){
//sidan för frånvarorapportering
return (
<View style={styles.container}>
/*<TouchableHighlight style={styles.logout_button} onPress={() => this.logout()}>
<Text style={styles.login_button_text}>Logga ut</Text>
</TouchableHighlight>*/
<View style={styles.report_wrapper}>
<Text style={styles.header}>Frånvarorapportering</Text>
<Text>Ange anledning och hur stor del av dagen du blir frånvarande.</Text>
<PickerIOS
selectedValue={this.state.reason}
onValueChange={(reason) => this.setState({reason})}>
{Object.keys(REASONS).map((reason) => (
<PickerItemIOS
key={reason}
value={reason}
label={REASONS[reason].name}
/>
))}
</PickerIOS>
</View>
</View>
);
}
else{
//inloggningssidan
return (
<View style={styles.container}>
<Image resizeMode="center" style={styles.logo} source={require('./app/res/logo_cmyk.png')} />
<TextInput
placeholder="Namn"
autocorrect={false}
style={styles.text_box}
onChangeText={(username) => this.setState({username})}
/>
<TextInput
placeholder="Lösenord"
autocorrect={false}
secureTextEntry={true}
style={styles.text_box}
onChangeText={(password) => {this.setState({password})}}
/>
<TouchableHighlight style={styles.login_button} onPress={() => this.login()}>
<Text style={styles.login_button_text}>Logga in</Text>
</TouchableHighlight>
</View>
);
}
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#F4F4F4',
},
report_wrapper: {
flex: 1,
},
logout_button: {
flex: 0,
flexDirection: "row",
justifyContent: "center",
alignItems: "center",
marginLeft: 10,
marginRight: 10,
marginTop: 30,
marginBottom: 2,
padding: 10,
backgroundColor: "#003878"
},
login_button: {
flex: 0,
flexDirection: "row",
justifyContent: "center",
alignItems: "center",
marginLeft: 10,
marginRight: 10,
marginTop: 2,
marginBottom: 2,
padding: 10,
backgroundColor: "#003878"
},
login_button_text: {
color: "white",
fontSize: 20,
flex: 1,
textAlign: "center",
},
logo: {
//flex: 1,
},
text_box: {
height: 40,
flex: 0,
backgroundColor: "white",
marginLeft: 10,
marginRight: 10,
marginTop: 2,
marginBottom: 2,
padding: 10
},
header: {
color: "#84754E",
fontSize: 25,
marginTop: 30,
},
});
AppRegistry.registerComponent('mbab_franvaro',() => mbab_franvaro);
में यह त्रुटि भी थी, और मुझे एक नई परियोजना शुरू करनी थी और एक-एक करके निर्भरताओं को एक-एक करके यह पता लगाने के लिए कि प्रतिक्रिया-देशी-राउटर-फ्लक्स से छुटकारा पाने के लिए यह मेरे लिए तय किया गया था। लेकिन मैं अभी भी थोड़ी देर में त्रुटि को पूरा करता हूं, लेकिन पुनः लोड होने के बाद चला गया है। – vonovak
@VojtaNovak प्रतिक्रिया-मूल-राउटर-फ्लक्स प्रतिक्रियात्मक मूल के कार्य में निर्मित है? मुझे इसके बारे में बहुत कुछ नहीं मिल रहा है, प्रतिक्रिया मूल की आधिकारिक वेबसाइट पर कुछ भी नहीं। जब तक मुझे कुछ याद नहीं आ रहा है, मुझे नहीं लगता कि मैं इसका उपयोग कर रहा हूं। विस्तार करने की देखभाल? –
यह एक नेविगेशन लाइब्रेरी है, मुझे लगता है कि आपको google के साथ कुछ मिल जाएगा :) लेकिन जैसा कि मैंने कहा था कि यह अब भी हर समय और फिर भी हो रहा है, लेकिन केवल सिम्युलेटर पर। – vonovak