summaryrefslogtreecommitdiff
path: root/client/app.jsx
blob: 6414fad5185bb3ff63e134e54a1dd16a9161db99 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import { useReducer } from 'react';
import { HashRouter } from 'react-router-dom';
import { Router } from './components/router';
import { SettingsContext } from './utils/settings_context';

const settingsReducer = (state, action) => {
  switch (action.type) {
    case 'update': {
      return { ...state, ...action.payload };
    }
  }
  return state;
};

export const App = () => {
  const [settings, dispatch] = useReducer(settingsReducer, window.SETTINGS);

  return (
    <SettingsContext.Provider value={[settings, dispatch]}>
      <HashRouter>
        <Router />
      </HashRouter>
    </SettingsContext.Provider>
  );
};