Comments (3)
I should definitely investigate this 😅 . Sorry for the delay, I'm quite busy at work these days :D
from server-push-hooks.
No problem, I worked around it by creating an alternative provider component, which is basically a copy of yours but I instead import SocketIOClient
from the package since you thankfully export it already, and then separated the useRef
and the socket.io connection calls. Not saying it's the best solution, but it served my purposes.
import React, {useRef} from 'react';
import io from 'socket.io-client';
// import { SocketIOContext } from "./context";
import {SocketIOContext} from 'use-socketio';
export interface ISocketIOProviderProps {
url: string;
opts?: SocketIOClient.ConnectOpts;
}
export const SocketIOProvider: React.FC<ISocketIOProviderProps> = ({
url,
opts,
children
}) => {
// const socketRef = useRef(io(url, opts || {}));
const socketRef = useRef<any>();
if (!socketRef.current) socketRef.current = io(url, opts || {});
return (
<SocketIOContext.Provider value={socketRef.current}>
{children}
</SocketIOContext.Provider>
);
};
from server-push-hooks.
Thanks to your snippet I've been able to fix this support quickly. Thank you so much for your help! It should be fixed and available in the 2.0.1 versions 😊 . Let me know if it works for you!
Have a great day :)
from server-push-hooks.
Related Issues (17)
- Can you use socket.on and socket.emit? HOT 1
- Support namespaces HOT 2
- Feature Request: Provide a way to delay the subscription HOT 4
- Feature Request: Provide a way to manually unsubscribe HOT 3
- Emit from client HOT 1
- Reduce unneeded code HOT 1
- 16.7.0-alpha.2 warning
- Version 2.0.1 is missing the check for window object in provider js file
- Library broken by 2.0.2 update HOT 3
- sse-server a bug HOT 5
- Websocket server example HOT 1
- Clarification on Readme Example HOT 1
- Status information, hooking into connection HOT 4
- Change return values HOT 2
- Missing prop 'children' in type of SocketIOProvider
- You are using `useEffect` in a wrong way HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from server-push-hooks.