mirror of
https://github.com/AmruthPillai/Reactive-Resume.git
synced 2025-11-19 19:21:33 +10:00
- designing the artboard - optimizing dark mode performance - optimizing input onChange handler
34 lines
714 B
JavaScript
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 };
|