LocChat/client/app.jsx

26 lines
631 B
React
Raw Normal View History

2021-11-20 21:34:10 -05:00
import { useReducer } from 'react';
import { HashRouter } from 'react-router-dom';
2021-11-20 20:18:58 -05:00
import { Router } from './components/router';
2021-11-20 21:34:10 -05:00
import { SettingsContext } from './utils/settings_context';
const settingsReducer = (state, action) => {
switch (action.type) {
case 'update': {
return { ...state, ...action.payload };
}
}
return state;
};
2021-11-16 21:14:46 -05:00
2021-11-20 20:18:58 -05:00
export const App = () => {
2021-11-20 21:34:10 -05:00
const [settings, dispatch] = useReducer(settingsReducer, window.SETTINGS);
2021-11-16 21:14:46 -05:00
return (
2021-11-20 21:34:10 -05:00
<SettingsContext.Provider value={[settings, dispatch]}>
<HashRouter>
<Router />
</HashRouter>
</SettingsContext.Provider>
2021-11-16 21:14:46 -05:00
);
};