Redux promise returns unresolved promises if type and payload parameters are specified

It’s hard for me to figure out why this is happening, but the promise was essentially cut for me, returning something like:

    return {
      type: STORY_ACTIONS.STORY_SPOTIFY_REQUEST,
      payload: request
    }

However, now I need to transmit the same information with him

    return {
     order: 0,
     type: STORY_ACTIONS.STORY_SPOTIFY_REQUEST,
     payload: request
    }

returning this result returns unresolved promises inside my reducer instead of data. I tried to rename orderto something like positionor indexnothing else. My first example is returnworking absolutely fine.

+4
source share
1 answer

redux-, . flux-standard-actions, :

import isPlainObject from 'lodash.isplainobject';

const validKeys = [
  'type',
  'payload',
  'error',
  'meta'
];

function isValidKey(key) {
  return validKeys.indexOf(key) > -1;
}

export function isFSA(action) {
  return (
    isPlainObject(action) &&
    typeof action.type !== 'undefined' &&
    Object.keys(action).every(isValidKey)
  );
}

export function isError(action) {
  return action.error === true;
}

, . , order " " , , "".

+6

Source: https://habr.com/ru/post/1628491/


All Articles