I have a react/redux/saga project and 2 forms (components): login and register. From those components I'm dispatching the corresponding actions which are related to the authentication reducer.
When the form submission is successful, I save the auth token in the store, that part is ok.
The problem comes when I get an error from the server, for example: "wrong user or password".
I don't think that information is relevant for being stored in redux state, but want to display the error in the form.
Options:
- a) If I store the error using the auth reducer, I have to clear errors before switching between login or register because the error field is shared.
- b) I could create 2 reducers, one for auth and another for handling the ui. Auth reducer would be interested in getting the token and ui in getting the error field from the ajax response.
- c) Not sure if this is correct, but, should I perform ajax from the component and store errors in the component state (or hooks)
redux-form library stores form state in the store, so maybe option b) is not so bad.
Which strategy is better?