Why state is not updated in the repository Redux?

Hello! For a couple of hours scratching their heads why not updated state.
There is an action that sends the value of the fields in the form (username and password) to the server and receives the response in plain string.
function app (state=initialState, action) {
 if (action.type === 'LOGIN') {
 if (!Object.keys(state.loginValue).length) return state;
 else {
 let data = JSON.stringify(state.loginValue);
 axios.post('http://localhost:80/signin', data, {
 headers: {
 'Content-Type': 'application/json'
}
})
 .then(res => {
 if (res.data !== 'All ok!') {
 console.log(Res. data); // Here everything is OK, the response from the server (string) comes
 return { // Here, in theory, should be updated to state, but it does not work 
...state
 loginWarning: res.data 
};
}
})
 .catch(() => state)
}
}
...
 return state;
}


Set a subscribe on state, and it fails because there is no change. How to fix it? In advance, thanks for any help!
April 7th 20 at 11:56
1 answer
April 7th 20 at 11:58
Solution
1. In redusere should not be asynchronous operations. Remove from axios reducer. It will not work.
2. You need a thunk. Here is an example of how to do it right https://alligator.io/redux/redux-thunk/
Completely forgot about this, thanks) - reuben commented on April 7th 20 at 12:01

Find more questions by tags ReactRedux