reasonml-community / bs-socket.io

Bindings to socket.io
MIT License
50 stars 13 forks source link

'io' is not defined #11

Open peterpme opened 4 years ago

peterpme commented 4 years ago

Hey everyone,

Awesome library! I'm running into an error. All I've done is

MyClient.re

module Client = BsSocket.Client.Make(Messages);
let socket = Client.createWithUrl("http://localhost:3000");

MyClient.bs.js

// Generated by BUCKLESCRIPT, PLEASE EDIT WITH CARE

import * as Curry from "bs-platform/lib/es6/curry.js";
import * as React from "react";
import * as Belt_Array from "bs-platform/lib/es6/belt_Array.js";
import * as Client$BsSocket from "bs-socket/src/Client.bs.js";
import * as Messages$Codenames from "./Messages.bs.js";

var Client = Client$BsSocket.Make(Messages$Codenames);

// ...

function Game(Props) {
  var id = Props.id;
  React.useEffect((function () {
          var socket = io(); <---- BREAKS HERE
          console.log(socket);
          console.log(id);
          return ;
        }), ([]));
}

Any help would be appreciated, thank you!

Am I supposed to be importing io somewhere?

ralake commented 4 years ago

Seems to work for me if you include the socket-ui script in the head of the html sync, rather than install socket.io as a package...