Created
May 1, 2020 14:10
-
-
Save willprice76/f1fceeb12154baee4c88f23cfae98d83 to your computer and use it in GitHub Desktop.
Using multiple reducers for different lifecycles
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//component state | |
const [{ data:initialData, isBusy:isLoading, hasError:loadingFailed, errorMessage:loadingError }, dispatch] = useReducer( | |
createActionReducer<Recipe[]>(), | |
{ isBusy: true, hasError: false } | |
); | |
const [{ data:updatedData, isBusy:isUpdating, hasError:updateFailed, errorMessage:updateError }, dispatch] = useReducer( | |
createActionReducer<Recipe[]>(), | |
{ isBusy: false, hasError: false } | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment