Skip to content

Commit

Permalink
🐛 Fix forceFetch option no longer working with getOrFetchItem and get…
Browse files Browse the repository at this point in the history
…OrFetchList
  • Loading branch information
greena13 committed Oct 1, 2020
1 parent 173da20 commit 5afb6a1
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/utils/getOrFetch.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,15 @@ function getOrFetch(options, resourcesState, params = {}, actionCreatorOptions =

const itemOrList = getFunction(resourcesState, key);

if (!localOnly && (!hasDefinedStatus(itemOrList) || evaluateForceCondition(actionCreatorOptions.forceFetch, itemOrList))) {
if (!isActionPending(action, key)) {
const forceAction = evaluateForceCondition(actionCreatorOptions.forceFetch, itemOrList);

if (!localOnly && (!hasDefinedStatus(itemOrList) || forceAction)) {
if (!isActionPending(action, key) || forceAction) {
enqueuePendingAction(action, key);

/**
* We wrap dispatching the action in setTimeout to defer it until the next render cycle, allowing you to
* use the method in a controller's render method, without triggering a warning from React about updating
* use the method in a component's render method, without triggering a warning from React about updating
* another component's state while it is rendering
*
* Note: The evaluating of whether an action is queued or not must still be done synchronously in order
Expand Down

0 comments on commit 5afb6a1

Please sign in to comment.