match context shape

This commit is contained in:
Josh Hawkins 2023-10-13 21:45:21 -05:00
parent a247571829
commit d8127a5592

View File

@ -5,7 +5,7 @@ import { useCallback, useContext, useEffect, useReducer } from 'preact/hooks';
import useWebSocket, { ReadyState } from 'react-use-websocket'; import useWebSocket, { ReadyState } from 'react-use-websocket';
const initialState = Object.freeze({ __connected: false }); const initialState = Object.freeze({ __connected: false });
export const WS = createContext({ state: initialState, connection: null }); export const WS = createContext({ state: initialState, readyState: null, sendJsonMessage: () => {} });
function reducer(state, { topic, payload, retain }) { function reducer(state, { topic, payload, retain }) {
switch (topic) { switch (topic) {