import {createContext, useReducer} from "react";
import { resultsReducer } from "../reducers/ResultsReducer";

export const ResultsContext = createContext(null)

const initialState = []

const ResultsContextProvider = (props) => {
  const [resultsList, dispatch] = useReducer(resultsReducer, initialState)

  return (
      <ResultsContext.Provider value={{resultsList, dispatch}}>
        {props.children}
      </ResultsContext.Provider>
  )
}

export default ResultsContextProvider;
