Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Version 2.0.1 is missing the check for window object in provider js file #34

Closed
khaled-hamam opened this issue May 24, 2020 · 0 comments · Fixed by #35
Closed

Version 2.0.1 is missing the check for window object in provider js file #34

khaled-hamam opened this issue May 24, 2020 · 0 comments · Fixed by #35

Comments

@khaled-hamam
Copy link
Contributor

I'm using the library with next.js as a server side rendering framework, and I found that there was unintended behavior happens as the socket is created in server side although it shouldn't due to this line:

// src/io/provider.ts
if (!window) {
  return <>{children}</>;
}

I found that the built js file didn't have this check, so I cloned the project, and run a build, and somehow that was the only line that didn't make it in the previous build (also package-lock version is on 1.0.1 if this matters).

Before Build (current state)

// lib/io/provider.js
var url = _a.url, opts = _a.opts, children = _a.children;
var socketRef = react_1.useRef();

After Build

var url = _a.url, opts = _a.opts, children = _a.children;
if (!window) {
  return react_1["default"].createElement(react_1["default"].Fragment, null, children);
}
var socketRef = react_1.useRef();
khaled-hamam added a commit to khaled-hamam/use-socketio that referenced this issue May 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant