React Component不会触发事件

时间:2016-09-28 11:37:15

标签: javascript node.js reactjs

我有这个用react + socket io制作的小聊天应用程序,这是一个基本的聊天,我将消息放在Test中。控制台看起来干净,没有问题,组件呈现,但套接字发出似乎不起作用。您可以在此处http://916ae18b.ngrok.io/

进行测试

/// App.js

<ul>

/// App.js

const express = require('express');
const app = express();
const webpack = require('webpack');
const webpackMiddleware = require('webpack-dev-middleware');
const config = require('./webpack.config.js');
const compiler = webpack(config);
const server = require('http').Server(app);
const io = require('socket.io')(server);

app.use(webpackMiddleware(compiler, {publicPath:config.output.publicPath}))
app.use(express.static(__dirname + '/src'))

io.on('connection', socket => {
    socket.on('message', data => socket.emit('message', data))
})

server.listen(3000, () => console.log('server is up!'))

0 个答案:

没有答案