Skip to content
This repository has been archived by the owner on Nov 10, 2017. It is now read-only.

Commit

Permalink
Defer importing socket io
Browse files Browse the repository at this point in the history
Fixes #1
  • Loading branch information
thani-sh committed Jun 18, 2016
1 parent 1f4f93a commit a309725
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
10 changes: 5 additions & 5 deletions dist/client/preview/components/Preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -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"); } }
Expand Down Expand Up @@ -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' });
Expand Down
5 changes: 4 additions & 1 deletion src/client/preview/components/Preview.js
Original file line number Diff line number Diff line change
@@ -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 = {
Expand All @@ -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});

Expand Down

0 comments on commit a309725

Please sign in to comment.