react-native-socketio icon indicating copy to clipboard operation
react-native-socketio copied to clipboard

Getting "Cannot read property 'initialize' of undefined"

Open BigPun86 opened this issue 9 years ago • 15 comments

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

BigPun86 avatar Jun 29 '16 10:06 BigPun86

+1

mcliquid avatar Jun 29 '16 11:06 mcliquid

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 avatar Jun 29 '16 15:06 gcrabtree

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

gcrabtree avatar Jun 30 '16 05:06 gcrabtree

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.

GeoffreyPlitt avatar Sep 12 '16 23:09 GeoffreyPlitt

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

jitenderchand1 avatar Oct 26 '16 12:10 jitenderchand1

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

i25878427 avatar Oct 29 '16 09:10 i25878427

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

huangjilaiqin avatar Dec 06 '16 03:12 huangjilaiqin

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

huangjilaiqin avatar Dec 06 '16 04:12 huangjilaiqin

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

LucasSouzaa avatar Mar 21 '17 21:03 LucasSouzaa

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)

Darex1991 avatar Mar 29 '17 10:03 Darex1991

who can fix this problem???

atlas1119 avatar Jun 14 '17 07:06 atlas1119

+1

felansu avatar Sep 15 '17 18:09 felansu

any update on this issue???

gogulanareshkw avatar Jul 03 '18 13:07 gogulanareshkw

@gogulanareshkw no.

felansu avatar Jul 03 '18 14:07 felansu

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!');
});

ciriac avatar Jul 03 '18 14:07 ciriac