samedi 4 avril 2015

Is it possible to combine React Native with socket.io

I was working on an app with Phonegap + React.js and Socket.io. However, then React-Native got released and the native feel is amazing.


I tried getting socket.io-client working with React Native, but unfortunately without much success. I did some research and I'm getting the exact same errors as described in this issue: http://ift.tt/1xCm1sK


The comments on the issue said to try and use the fetch API to fetch JS modules, but I think I'm doing this wrong:



var socketScript;
fetch('http://ift.tt/1pV2OyR')
.then(function(response) {
socketScript = response._bodyText;
}).done(function() {
var socket = socketScript.io();
});


This returns an undefined is not a function.


Is there any way to make socket.io-client work with React Native? Or am I looking at this the wrong way? Perhaps there are other, better suited solutions?


Aucun commentaire:

Enregistrer un commentaire