Skip to content

Commit

Permalink
Avoid unnecessary re-renders by comparing errors to previous errors
Browse files Browse the repository at this point in the history
  • Loading branch information
mvestergaard committed Nov 26, 2019
1 parent 37870bf commit 5ded232
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/Formik.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ function formikReducer<Values>(
case 'SET_TOUCHED':
return { ...state, touched: msg.payload };
case 'SET_ERRORS':
if (isEqual(state.errors, msg.payload)) {
return state;
}

return { ...state, errors: msg.payload };
case 'SET_STATUS':
return { ...state, status: msg.payload };
Expand Down

0 comments on commit 5ded232

Please sign in to comment.