diff --git a/components/form/form.js b/components/form/form.js index 5f77304..65bfd36 100644 --- a/components/form/form.js +++ b/components/form/form.js @@ -26,7 +26,7 @@ const errorReducer = (errors, action) => { } } -const formReducer = (state, action)=>{ +const formReducer = errorDispatch => (state, action)=>{ let fields = {...state.fields} const prevField = state.fields[action.name] @@ -91,8 +91,8 @@ export const FormController = function FormController({children, url, method = }) // Create reducers - const [state, dispatch] = useReducer(formReducer, initialState) const [errors, errorDispatch] = useReducer(errorReducer, {}) + const [state, dispatch] = useReducer(formReducer(errorDispatch), initialState) // Handle submitting form const handleSubmit = async (ev) => {