From 8a2ad8b50e7dfbd874f6f84c4093e1e4b8be18de Mon Sep 17 00:00:00 2001 From: seakrebel <16282150+seakrebel@users.noreply.github.com> Date: Sat, 19 Mar 2022 17:05:48 +0100 Subject: [PATCH] Reversing order of errors before using .map in function `handleSubmit` errors were being mapped from first to last, last being the only saved one (and shown to the user), which was wrong. Reversing the array before map() fixes this issue. --- lib/create-form.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/create-form.js b/lib/create-form.js index b88c069..2e9947a 100644 --- a/lib/create-form.js +++ b/lib/create-form.js @@ -151,7 +151,7 @@ export const createForm = (config) => { if (yupErrors && yupErrors.inner) { const updatedErrors = getInitial.errors(); - yupErrors.inner.map((error) => + yupErrors.inner.reverse().map((error) => util.set(updatedErrors, error.path, error.message), );