Coder Social home page Coder Social logo

socket.io-react's People

Contributors

emision avatar lemaik avatar sergiodxa avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

socket.io-react's Issues

Import doesn't work as shown in the readme

When using Webpack+Babel, due to the way SocketProvider and socketConnect are re-exported here, they can't be imported with import { SocketProvider, socketConnect } from 'socket.io-react' but only by importing the default export and then de-structuring that object.

Thank you for the great component! ๐Ÿ‘

Dependency issue in this package

It's mentioned on package that there is no dependency :
screen shot 2017-08-04 at 3 36 19 pm

But after installation it gave me error :
โ”œโ”€โ”€ UNMET PEER DEPENDENCY [email protected]
โ”œโ”€โ”€ UNMET PEER DEPENDENCY [email protected]
โ””โ”€โ”€ [email protected]

While if you see my package json :
"react": "15.4.2",
"socket.io-client": "2.0.3",
"socket.io-react": "1.2.0",

All the required packages are already there. Please test your plugin once before publishing.

No type definitions

I'm having trouble using this library with typescript because it doesn't provide it's own type definitions and there isn't a @types/socket.io-react.

Is this something that's possible to add in the future?

`socket.io-client` disappears while trying to run

Hi,

I followed your instruction, but failed to config, because I cannot import io from 'socket.io-client'; while going for SocketProvider(socket?). I was afraid socket.io-react didn't exist in node_modules folder?

Support for React version 18.*

My react project is currently using "react": "^18.2.0"

The installation of the socket io client throws a compatibility error.

Given the error, I think the socket.io-client package is only compatible with the react version till 15.6.1

image

I guess this means, I force the installation or downgrade my react version which I think is not the right way to go.

The socket client should be able to work with the latest react versions.

Update npm version

I'm using the npm published version, and it is not updated with the PropTypes thingy

Socket.io-react with create react app

I am trying to use socket.io-react with create-react-app. I have attached node backend at port 3001 and create-react-app development server at port 3000.

My code looks like -

// index.js
import {SocketProvider} from 'socket.io-react';
import io from 'socket.io-client';

import App from './components/app/App.js';
import React from 'react';
import ReactDOM from 'react-dom';

const socket = io('http://localhost:3001');
socket.on('message', msg => console.log(msg));

ReactDOM.render(
  <SocketProvider socket={socket}>
    <App />
  </SocketProvider>,
  document.getElementById('root')
);
// server.js
const app = require('express')();
const path = require('path');
const mongoose = require('mongoose');
const bodyParser = require('body-parser');
const socketServer = require('http').Server(app);
const io = require('socket.io')(socketServer);

const Stock = require('./models/stock.js');
const routes = require('./app/routes.js');

// loads all custom environments variables
if (process.env.NODE_ENV !== "production") {
  require('dotenv').config();
}

socketServer.listen(3002);
app.set('port', (process.env.PORT || 3001));

io.on('connection', function(socket) {
        console.log('a user connected, id ' + socket.id);
        socket.on('disconnect', function() {
            console.log('a user disconnected, id '  + socket.id);
        })
})

...

and I am getting the following error in console -

GET http://localhost:3001/socket.io/?EIO=3&transport=polling&t=Ldg56In 404 (Not Found)
Request.create @ polling-xhr.js:261
Request @ polling-xhr.js:166
XHR.request @ polling-xhr.js:93
XHR.doPoll @ polling-xhr.js:123
Polling.poll @ polling.js:118
Polling.doOpen @ polling.js:63
Transport.open @ transport.js:80
Socket.open @ socket.js:240
Socket @ socket.js:119
Socket @ socket.js:29
Manager.open.Manager.connect @ manager.js:213
(anonymous) @ manager.js:527

localhost/:1 XMLHttpRequest cannot load http://localhost:3001/socket.io/?EIO=3&transport=polling&t=Ldg56In. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:3000' is therefore not allowed access. The response had HTTP status code 404.

What should i do to make the setup work and what is the process.env.SOCKET_URL?

Thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.