I've read some qestions about errors in redux but still not quite understand it.
For example in my app I have activeUser reducer where I store null or object with logged user. It listens to actions and changes its state if needed. Simple.
But how errors reducers should work and look?
I did my errors reducers this way:
I have single error/index.js file where I store all errors reducers:
import * as actionTypes from '../../constants'
export const wrongUsername = (state = false, action) => {
switch (action.type) {
case actionTypes.WRONG_USERNAME:
return state = true
case actionTypes.RESET_ERRORS:
return state = false
default:
return state
}
}
export const wrongPassword = (state = false, action) => {
switch (action.type) {
case actionTypes.WRONG_PASSWORD:
return state = true
case actionTypes.RESET_ERRORS:
return state = false
default:
return state
}
}
export const usernameIsTaken = (state = false, action) => {
switch (action.type) {
case actionTypes.USERNAME_IS_TAKEN:
return state = true
case actionTypes.RESET_ERRORS:
return state = false
default:
return state
}
}
And this is my reducers/index.js file wher I combine all my reducers:
const reducers = combineReducers({
activeUser,
viewableUser,
isLoading,
isFriend,
userMessages,
users,
wasRequestSend,
wrongUsername,
wrongPassword,
usernameIsTaken
})
is this normal or not? Should I change structure of my errors reducers?