import React, { createContext, useContext, useReducer } from "react";
import ReactDOM from "react-dom";
const CounterContext = createContext();
const reducer = (state, action) => {
  switch (action.type) {
    case "ADD_TO_COUNTER": {
      return {
        ...state,
        counter: state.counter + action.value
      };
    }
    default:
      return state;
  }
};
const initialState = {
  counter: 0
};
const CounterContextProvider = props => {
  const [state, dispatch] = useReducer(reducer, initialState);
  return (