Skip to content
This repository has been archived by the owner on May 15, 2023. It is now read-only.

Commit

Permalink
log current user inside render() function of app component
Browse files Browse the repository at this point in the history
  • Loading branch information
pacificpelican committed Jun 15, 2017
1 parent b2f3c25 commit adb4325
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 7 deletions.
2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "ychat",
"version": "0.4.13",
"version": "0.5.0",
"private": true,
"dependencies": {
"react": "^15.5.4",
Expand Down
25 changes: 19 additions & 6 deletions src/App.js
Expand Up @@ -10,12 +10,17 @@ var socket = require('socket.io-client')('http://localhost:3000');

var request = require('superagent');

request.
function getloggedinuser() {
request.
get('/currentusername')
.end(function(err, res){
console.log("ran request for user name:")
console.log("res.text:")
console.log(res.text);
return res.text;
});
}

const currentuser = getloggedinuser();

console.log(socket);
socket.on('news', function (data) {
Expand Down Expand Up @@ -118,15 +123,14 @@ class MyInput extends Component {
}

class App extends Component {
state = { data: {} };
state = { theuser: {currentuser} };

constructor() {
super();

}

componentDidMount() {
console.log('about so set socket state');
console.log('about to set socket state');
// import io from 'socket.io-client'

console.log(socket);
Expand All @@ -142,10 +146,19 @@ class App extends Component {
}

render() {
var thisuser;
request.
get('/currentusername')
.end(function(err, res){
thisuser = res.text;
console.log("thisuser")
console.log(thisuser);
});
console.log('username in render function: ' + thisuser);
if ((params !== 'undefined') && (params !== undefined)) {
return (
<div className="App">
<MyInput />
<MyInput loggeduser={thisuser} />
</div>
);
}
Expand Down

0 comments on commit adb4325

Please sign in to comment.