Skip to content
Snippets Groups Projects
Commit d1e09081 authored by ric's avatar ric
Browse files

user data

parent 0343cb69
No related branches found
No related tags found
No related merge requests found
...@@ -10,16 +10,22 @@ class ChatScreen extends Component { ...@@ -10,16 +10,22 @@ class ChatScreen extends Component {
this.state = { this.state = {
msg : "", msg : "",
msgList: [], msgList: [],
user: this.props.route.params.user
}; };
} }
componentDidMount() { componentDidMount() {
//Now we have the informations about the user
//so we can display for example the name in
//themessages
//const {user} = this.props.route.params;
//alert(user.username);
this.socket = io("http://192.168.196.145:3000", { //192.168.178.92 ric ip this.socket = io("http://192.168.196.145:3000", { //192.168.178.92 ric ip
transports: ['websocket'] //this line is fundamental transports: ['websocket'] //this line is fundamental
}); });
this.socket.on('msg', msg =>{ this.socket.on('msg', msg =>{
alert(msg);
this.setState({msgList: [...this.state.msgList, msg]}) this.setState({msgList: [...this.state.msgList, msg]})
}) })
} }
......
import React from 'react';
import { StyleSheet, Text, View } from 'react-native';
class HomeScreen extends React.Component {
render() {
return (
<View style={styles.container}>
<Text>HOMEPAGE</Text>
</View>
);
}
}
// ...
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff',
alignItems: 'center',
justifyContent: 'center',
},
});
export default HomeScreen;
...@@ -31,7 +31,10 @@ class LoginScreen extends Component { ...@@ -31,7 +31,10 @@ class LoginScreen extends Component {
console.log(obj.body.result); console.log(obj.body.result);
if (obj.status == 200) { if (obj.status == 200) {
alert('Succesful login') alert('Succesful login')
this.props.navigation.navigate('Chat', {user : obj.body.result}) this.props.navigation.navigate('Chat', {
screen : 'Chat',
params: {user : obj.body.result},
})
} }
else if (obj.status == 201){ else if (obj.status == 201){
alert('Succesful login') alert('Succesful login')
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment