All Questions
1,043
questions
79
votes
3
answers
65k
views
Proper way of using React hooks + WebSockets
I need to connect to WebSockets server and log it's messages. With React class component I'd put this logic in componentDidMount lifecycle hook and move on happily, but I'm not sure how to properly ...
31
votes
2
answers
52k
views
Using WebSockets with Next.js
I'm wondering what's the best approach to connect into my WebSockets server using Next.js' pages? I'd like that the user could navigate through the pages with one connection, and when he closes the ...
24
votes
3
answers
47k
views
Proper way of using WebSockets with React Native
I'm new to React Native, but very familiar with React. As a beginner I'm looking to setup a connection between a cloud server and react-native with websockets as I've seen in the documentation. ...
22
votes
4
answers
15k
views
How to run socket.io in the background on iOS in a React Native app?
I am using socket.io in an iOS React Native(v0.20) app. The app tracks my location, and when my position changes it emits a message to a server. If the socket connection is lost the server sends an ...
19
votes
1
answer
15k
views
How to implement long polling for React + axios
I'm using React + axios to talk to the API from the client side. I'm a newbie in JavaScript.
How would I implement long polling so I get near real-time updates on a web page?
Is there a better way ...
17
votes
6
answers
22k
views
Reactjs: how to share a websocket between components
I'm new to React and I'm having some issues regarding components structure and sharing a websocket between them.
The app consists of categories and products. The initial data load will be done with ...
16
votes
5
answers
43k
views
how react js acts as a websocket client?
I want to create a Websocket based client-server Application. In that I'm created node js websocket server which is waiting for the clients. Now I want to create react js websocket client. I'm using ...
16
votes
2
answers
18k
views
state inside useEffect refers the initial state always with React Hooks
Every time I emit a message from another component, I can't get the full list of messages. Here is the hook and view component:
export function useChat() {
const [messages, setMessages] = useState([...
12
votes
5
answers
34k
views
WebSocketClient.js:16 WebSocket connection to 'ws://localhost:3000/ws' failed: React, Docker, NGINX
Here's the issue... when I start a React app locally as npm start. I don't have a ws failed connection.
If I start NGINX and React servers within Docker containers I constantly get
WebSocketClient.js:...
10
votes
2
answers
10k
views
Using AWS Lambda to watch SNS topic and deliver by websocket?
For testing/debugging purposes, I would create a web app that emulates the functionality of one of the 3rd party actors in our system. It should be able to publish and subscribe to messages sent on ...
9
votes
2
answers
36k
views
Receiving Error: xhr poll error socket.io client React
I am receiving an Error: xhr poll error in the connect_error event when trying to connect to my websocket gateway.
I am using "socket.io-client": "^4.2.0".
import { io } from "...
9
votes
3
answers
15k
views
WebSockets in Create React App with Webpack proxy
I created my React app using Create React App in version 3.1.2 (19 Sept 2019). I was trying to configure proxy for Web Socket requests, but it seems that when I am using the proxy, the connection is ...
9
votes
1
answer
11k
views
Best practices for React, Redux and Websocket (Keeping one class to handle requests)
This question is related to React, Redux and Websocket (socket.io).
In this approach I want to update my UI real time. I’m opening individual sockets in each componentDidMount in each file which I ...
9
votes
2
answers
6k
views
How to test Websocket Client with Jest and react-testing-library
I'm using create-react-app, Jest and react-testing-library for the configuration of the chatbot project.
I have a React functional component that connects to a WebSocket server and DOM changes ...
8
votes
4
answers
19k
views
Can I use the React Context API inside a Context API or do I have to merge them?
I am just curios about if it would be possible to use the Context API inside a Context API. Like for example I would have a Context API for an AppState and want to use that in another Context API ...