Files
Reactive-Resume/src/contexts/ResumeContext.js
Amruth Pillai 202c7f5ad4 - creating the right sidebar
- designing the artboard
- optimizing dark mode performance
- optimizing input onChange handler
2020-07-05 11:34:32 +05:30

34 lines
714 B
JavaScript

import { set } from "lodash";
import React, { createContext, useReducer } from "react";
const initialState = {
profile: {
photograph: "",
firstName: "",
lastName: "",
},
};
const ResumeContext = createContext(initialState);
const ResumeProvider = ({ children }) => {
const [state, dispatch] = useReducer((state, { type, payload }) => {
switch (type) {
case "on_input":
return set({ ...state }, payload.path, payload.value);
default:
throw new Error();
}
}, initialState);
return (
<ResumeContext.Provider value={{ state, dispatch }}>
{children}
</ResumeContext.Provider>
);
};
export default ResumeContext;
export { ResumeProvider };