Use ReconnectingWebSocket instead of vanilla WebSocket (#348)
This commit is contained in:
parent
90f2672bc0
commit
a4ac2979c8
@ -24,6 +24,7 @@
|
|||||||
"react-markdown": "^8.0.3",
|
"react-markdown": "^8.0.3",
|
||||||
"react-plotly.js": "^2.6.0",
|
"react-plotly.js": "^2.6.0",
|
||||||
"react-syntax-highlighter": "^15.5.0",
|
"react-syntax-highlighter": "^15.5.0",
|
||||||
|
"reconnecting-websocket": "^4.4.0",
|
||||||
"rehype-katex": "^6.0.2",
|
"rehype-katex": "^6.0.2",
|
||||||
"rehype-raw": "^6.1.1",
|
"rehype-raw": "^6.1.1",
|
||||||
"remark-gfm": "^3.0.1",
|
"remark-gfm": "^3.0.1",
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
// State management for Pynecone web apps.
|
// State management for Pynecone web apps.
|
||||||
|
import ReconnectingWebSocket from 'reconnecting-websocket';
|
||||||
|
|
||||||
// Global variable to hold the token.
|
// Global variable to hold the token.
|
||||||
let token;
|
let token;
|
||||||
@ -136,7 +137,7 @@ export const updateState = async (state, setState, result, setResult, router, so
|
|||||||
*/
|
*/
|
||||||
export const connect = async (socket, state, setState, result, setResult, router, endpoint) => {
|
export const connect = async (socket, state, setState, result, setResult, router, endpoint) => {
|
||||||
// Create the socket.
|
// Create the socket.
|
||||||
socket.current = new WebSocket(endpoint);
|
socket.current = new ReconnectingWebSocket(endpoint);
|
||||||
|
|
||||||
// Once the socket is open, hydrate the page.
|
// Once the socket is open, hydrate the page.
|
||||||
socket.current.onopen = () => {
|
socket.current.onopen = () => {
|
||||||
|
Loading…
Reference in New Issue
Block a user