aboutsummaryrefslogtreecommitdiff
path: root/src/console/app/provider.tsx
blob: 397f1656af0c4818461d66ecab82727d849956d3 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
import React from "react";
import reducer, { defaultState } from "./recuer";
import { AppDispatchContext, AppStateContext } from "./contexts";

export const AppProvider: React.FC = ({ children }) => {
  const [state, dispatch] = React.useReducer(reducer, defaultState);
  return (
    <AppStateContext.Provider value={state}>
      <AppDispatchContext.Provider value={dispatch}>
        {children}
      </AppDispatchContext.Provider>
    </AppStateContext.Provider>
  );
};