gcrabtree / react-native-socketio

Not Maintained! A React Native wrapper for both the Swift and Java Socket.Io clients.
MIT License
152 stars 53 forks source link

Getting "Cannot read property 'initialize' of undefined" #7

Open BigPun86 opened 8 years ago

BigPun86 commented 8 years ago

screen shot 2016-06-29 at 12 23 29

screen shot 2016-06-29 at 12 25 04

screen shot 2016-06-29 at 12 25 16

I notified when integrating this module to my xcode project, it gives me some warnings:

screen shot 2016-06-29 at 12 27 22

Did anyone experience similar issue?

Running on RN 28 and testing with your example code

mcliquid commented 8 years ago

+1

gcrabtree commented 8 years ago

I'll take a look sometime tonight.

I haven't upgraded support to RN 0.28 as the project we are working on had major issues with that release (outside of this library). We are currently running on RN 0.25.1.

Will keep you posted.

gcrabtree commented 8 years ago

Yeah, there are breaking API changes between those two releases (RN 0.25 and RN 0.28). That would explain the deprecation warnings. I will migrate those to the new RCTEventEmitter class in a new release that supports 28+. They should probably still work in RN 28, but I'll need to update them moving forward.

@BigPun86 or @mcliquid WRT the undefined error, how are you importing socketio? I need to re-read the documentation that I have. The previous project (that appears to be dead) that I forked this from (spiritually, not an actual fork), had that original ios example. It's likely not working so I'll need to fix that up as well.

For now, this is how I include socketio and have it working on RN 25:

let io = require('react-native-socketio');
let socket = new io(url, socketioOptions); 
socket.connect();

Let me know if that gets you past the undefined problem.

There are a few issues with the packager with RN 28. https://github.com/facebook/react-native/issues/8297 https://github.com/facebook/react-native/issues/8409

GeoffreyPlitt commented 8 years ago

I can confirm this is broken with the latest RN (0.32). Does anyone have a fix?

In the meantime, I'd suggest a big warning on the README so people don't waste their time.

jitenderchand1 commented 8 years ago

I am getting the this.socket undefined with react native 0.35

i25878427 commented 8 years ago

I am getting the this.socket undefined with react native 0.31

huangjilaiqin commented 7 years ago

I am getting the this.socket undefined with react native 0.37.0

huangjilaiqin commented 7 years ago

I am getting the this.socket undefined with react native 0.37.0

Answer: I forgot change getPackages on MainApplication.java

README.md 3.Register module (in MainActivity.java) is error!!! is should change to: 3.Register module (in MainApplication.java) @gcrabtree hope help

LucasSouzaa commented 7 years ago

i'm getting this issue in react-native 0.42 in iOS only

Darex1991 commented 7 years ago

The same. Error on iOS I tried 0.39.2, 0.40.0, 0.41.0, 0.42.3 and this bug still exist.

TypeError: Cannot read property 'initialize' of undefined at new Socket (http://localhost:8081/index.ios.bundle?platform=ios&dev=true&minify=false:68738:13) at GameLobby.createLobbySocket (http://localhost:8081/index.ios.bundle?platform=ios&dev=true&minify=false:69173:12) at GameLobby.componentWillMount (http://localhost:8081/index.ios.bundle?platform=ios&dev=true&minify=false:69040:37) at http://localhost:8081/index.ios.bundle?platform=ios&dev=true&minify=false:19500:24 at measureLifeCyclePerf (http://localhost:8081/index.ios.bundle?platform=ios&dev=true&minify=false:19117:8) at ReactCompositeComponentWrapper.performInitialMount (http://localhost:8081/index.ios.bundle?platform=ios&dev=true&minify=false:19499:1) at ReactCompositeComponentWrapper.mountComponent (http://localhost:8081/index.ios.bundle?platform=ios&dev=true&minify=false:19378:13) at Object.mountComponent (http://localhost:8081/index.ios.bundle?platform=ios&dev=true&minify=false:17462:29) at Object.obj.(anonymous function) [as mountComponent] (eval at initialize (http://localhost:8081/index.ios.bundle?platform=ios&dev=true&minify=false:34422:1), :1217:27) at Constructor.mountChildren (http://localhost:8081/index.ios.bundle?platform=ios&dev=true&minify=false:18389:32)

atlas1119 commented 7 years ago

who can fix this problem???

felansu commented 7 years ago

+1

gogulanareshkw commented 6 years ago

any update on this issue???

felansu commented 6 years ago

@gogulanareshkw no.

ciriac commented 6 years ago

Is there really a need to still be using this library? If you're running the latest RN version you can just use socket.io-client without any issue.

yarn add socket.io-client

import SocketIOClient from 'socket.io-client';

const socket = new SocketIOClient('your_domain', {
   transports: ['websocket']
});

socket.connect();

socket.on('connect', () => {
   console.log('connected!');
});