This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from "react"; | |
import io from "socket.io-client"; | |
class Chat extends React.Component{ | |
constructor(props){ | |
super(props); | |
this.state = { | |
username: '', | |
message: '', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var express = require('express'); | |
var socket = require('socket.io'); | |
var app = express(); | |
server = app.listen(8080, function(){ | |
console.log('server is running on port 8080') | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { Component } from 'react'; | |
import Chat from "./Chat"; | |
class App extends Component { | |
render() { | |
return ( | |
<div> | |
<Chat/> | |
</div> | |
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from "react"; | |
class Chat extends React.Component{ | |
render(){ | |
return ( | |
<div className="container"> | |
<div className="row"> | |
<div className="col-4"> | |
<div className="card"> | |
<div className="card-body"> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from "react"; | |
class Chat extends React.Component{ | |
constructor(props){ | |
super(props); | |
this.state = { | |
username: '', | |
message: '', | |
messages: [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div className="messages"> | |
{this.state.messages.map(message => { | |
return ( | |
<div>{message.author}: {message.message}</div> | |
) | |
})} | |
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var express = require('express'); | |
var app = express(); | |
server = app.listen(8080, function(){ | |
console.log('server is running on port 8080') | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var socket = require('socket.io'); | |
io = socket(server); | |
io.on('connection', (socket) => { | |
console.log(socket.id); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from "react"; | |
import io from "socket.io-client"; | |
class Chat extends React.Component{ | |
constructor(props){ | |
super(props); | |
this.state = { | |
username: '', | |
message: '', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<button onClick={this.sendMessage} className="btn btn-primary form-control">Send</button> |
OlderNewer