diff --git a/packages/rest-hooks/src/state/NetworkManager.ts b/packages/rest-hooks/src/state/NetworkManager.ts index f8cfc405690..46bdba4fbc0 100644 --- a/packages/rest-hooks/src/state/NetworkManager.ts +++ b/packages/rest-hooks/src/state/NetworkManager.ts @@ -51,8 +51,6 @@ export default class NetworkManager implements Manager { // It's important to intercept other fetches as we don't want to trigger reducers during // render - so we need to stop 'readonly' fetches which can be triggered in render if (action.meta.optimisticResponse !== undefined) { - /* istanbul ignore next */ - if (process.env.NODE_ENV !== 'production') action.meta.nm = true; return next(action); } return Promise.resolve(); diff --git a/packages/rest-hooks/src/state/reducer.ts b/packages/rest-hooks/src/state/reducer.ts index a75b56956b5..414ae0b5bc2 100644 --- a/packages/rest-hooks/src/state/reducer.ts +++ b/packages/rest-hooks/src/state/reducer.ts @@ -28,18 +28,20 @@ export default function reducer( if (!state) state = initialState; switch (action.type) { case FETCH_TYPE: { - // If 'fetch' action reaches the reducer there are no middlewares installed to handle it - if (process.env.NODE_ENV !== 'production' && !action.meta.nm) { - console.warn( - 'Fetch appears unhandled - you are likely missing the NetworkManager middleware', - ); - console.warn( - 'See https://resthooks.io/docs/guides/redux#indextsx for hooking up redux', - ); + const optimisticResponse = action.meta.optimisticResponse; + if (optimisticResponse === undefined) { + // If 'fetch' action reaches the reducer there are no middlewares installed to handle it + if (process.env.NODE_ENV !== 'production') { + console.warn( + 'Fetch appears unhandled - you are likely missing the NetworkManager middleware', + ); + console.warn( + 'See https://resthooks.io/docs/guides/redux#indextsx for hooking up redux', + ); + } + return state; } - const optimisticResponse = action.meta.optimisticResponse; - if (optimisticResponse === undefined) return state; return { ...state, optimistic: [