mirror of
https://github.com/Mastermindzh/react-starter-kit.git
synced 2025-08-23 17:44:52 +02:00
Moved examples into example directory
Moved routes to separate file Used route constants
This commit is contained in:
@@ -0,0 +1,13 @@
|
||||
import { createAsyncThunk } from "@reduxjs/toolkit";
|
||||
import { fetchCount } from "../../services/counterAPI";
|
||||
|
||||
// The function below is called a thunk and allows us to perform async logic. It
|
||||
// can be dispatched like a regular action: `dispatch(incrementAsync(10))`. This
|
||||
// will call the thunk with the `dispatch` function as the first argument. Async
|
||||
// code can then be executed and other actions can be dispatched. Thunks are
|
||||
// typically used to make async requests.
|
||||
export const incrementAsync = createAsyncThunk("counter/fetchCount", async (amount: number) => {
|
||||
const response = await fetchCount(amount);
|
||||
// The value we return becomes the `fulfilled` action payload
|
||||
return response.data;
|
||||
});
|
Reference in New Issue
Block a user