From a309725ba8e849b035788fca1c5b5946d9a2de33 Mon Sep 17 00:00:00 2001 From: Muhammed Thanish Date: Sat, 18 Jun 2016 14:12:43 +0530 Subject: [PATCH] Defer importing socket io Fixes #1 --- dist/client/preview/components/Preview.js | 10 +++++----- src/client/preview/components/Preview.js | 5 ++++- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/dist/client/preview/components/Preview.js b/dist/client/preview/components/Preview.js index 6572ff6..b616eb3 100644 --- a/dist/client/preview/components/Preview.js +++ b/dist/client/preview/components/Preview.js @@ -14,10 +14,6 @@ var _CenteredText = require('./CenteredText'); var _CenteredText2 = _interopRequireDefault(_CenteredText); -var _socket = require('socket.io-client/socket.io'); - -var _socket2 = _interopRequireDefault(_socket); - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } @@ -50,8 +46,12 @@ var Preview = function (_Component) { value: function componentDidMount() { var _this2 = this; + // this fixes the window.navigator.userAgent issue + // TODO: find out why it's working when set this way + var io = require('socket.io-client/socket.io'); + // new connection - this.socket = (0, _socket2.default)(this.props.address, { jsonp: false }); + this.socket = io(this.props.address, { jsonp: false }); // initial setup this.socket.emit('init', { type: 'device' }); diff --git a/src/client/preview/components/Preview.js b/src/client/preview/components/Preview.js index 6d7b53e..814363f 100644 --- a/src/client/preview/components/Preview.js +++ b/src/client/preview/components/Preview.js @@ -1,6 +1,5 @@ import React, { Component } from 'react'; import CenteredText from './CenteredText'; -import io from 'socket.io-client/socket.io'; export default class Preview extends Component { static propTypes = { @@ -15,6 +14,10 @@ export default class Preview extends Component { } componentDidMount() { + // this fixes the window.navigator.userAgent issue + // TODO: find out why it's working when set this way + const io = require('socket.io-client/socket.io'); + // new connection this.socket = io(this.props.address, {jsonp: false});