I have such code with [email protected]
import React, { AsyncStorage, Component, View, Text, WebView, WebSocket } from 'react-native';
import { Avatar, Divider, Subheader, COLOR } from 'react-native-material-design';
export default class Avatars extends Component {
_setWebSocket = (endpoint, sessionToken) => {
const ws = new WebSocket('wss://' + endPoint + '/api/live?authToken=' + sessionToken);
console.log('Setting socket: ' + 'wss://' + endpoint + '/api/live?authToken=' + sessionToken);
and I'm calling code from:
componentDidMount() {
this._setWebSocket(endpoint, token);
}
I have issue with trying to get WebSockets to be working as code:
console.log('Setting socket: ' + 'wss://' + endpoint + '/api/live?authToken=' + sessionToken);
never is triggered . If I put console log before creating new WebSocket it runs. What I'm doing wrong and how can I debug as chrome isn't showing useful information in combination with Genymotion.
Issue was easy to find and probably I was tired
import React, { AsyncStorage, Component, View, Text, WebView, WebSocket } from 'react-native';
I put WebSocket to be imported but this is native module ... So removing WebSocket from import dependencies helped.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With