File size: 450 Bytes
c6be9e8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
// contexts/User/index.jsx

import React from 'react';
import { initialState, reducer } from './reducer';

export const StatusContext = React.createContext({
  state: initialState,
  dispatch: () => null,
});

export const StatusProvider = ({ children }) => {
  const [state, dispatch] = React.useReducer(reducer, initialState);

  return (
    <StatusContext.Provider value={[state, dispatch]}>
      {children}
    </StatusContext.Provider>
  );
};