import React, { useReducer, useContext } from "react"; import { useFetch } from "use-http"; import { TicketContext as ProviderContext } from "../../components/home/Tickets.service"; // define initial state const initialState = { ticketId: 0, ticket: {}, initData: {}, }; // difine reducer const reducer = (state, { type, ...action }) => { return actions[type](state, action); }; // export actions const actions = {}; // export and define only hooks export default function usePage() { const [state, dispatch] = useReducer(reducer, initialState); const fetch = useFetch({}); const ProviderValue = useContext(ProviderContext); return [state, dispatch, fetch, ProviderValue]; } // export and define only Context export const Context = React.createContext(null);