Created
August 3, 2020 17:43
-
-
Save Rajatgms/be285ab0e34b1c99554a9b7422dc39b5 to your computer and use it in GitHub Desktop.
Async Action Condition
This file contains hidden or 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
import { createAsyncThunk } from '@reduxjs/toolkit'; | |
import fetchMarketItems from '../API/fetchMarketItems'; | |
export const fetchAllItems = createAsyncThunk( | |
'items/fetchAllItems', | |
fetchMarketItems, | |
{ | |
condition: (arg, api) => { | |
return !api.getState().items.length > 0; | |
}, | |
}, | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment