Closed TecKnow closed 3 years ago
It was decided that individual React components should not call the API directly. Instead, they should use the useDispatch()
hook of react-rdux and call asynchronous action creators (thunks). Thunks are created using the createAsyncThunk()
function of @reduxjs-toolkit so exceptions are handled by dispatching <ActionType>.rejected
actions. Special handling for erros on adding a new player, compared to any other error, is no longer required.
Errors can be handled in the component that dispatched the thunk using _@reduxjs-toolkit__ unwrapResult()
or with reducers. Please see []Redux Essentials, Part 5: Async Logic and Data Fetching](https://redux.js.org/tutorials/essentials/part-5-async-logic) for an example of using unwrapResult()
.
https://github.com/TecKnow/muster-tools/blob/b3f3d2531a598041a8c535128dd63f5e1fec30f5/muster_client/src/Signin.js#L45-L45