Раньше это работало нормально, но теперь я получаю ошибку TypeError: Invalid attempt to spread non-iterable instance
.Что это значит под spread non-iterable instance
?
Я звоню, чтобы получить список идентификаторов пользователей, а затем бегу по каждому идентификатору, чтобы получить добавочные конвои, а затем добавляю к редуксу.Ранее это работало нормально, а теперь выдает вышеуказанную ошибку.
this.props.matchUserIds.matchUserIds.matchUserIds.map(id => {
apiHelper.getProfileInfo(token, id).then(results => {
const match = results.data.data
match.isBlocked = false
apiHelper.getConvoByUsers(this.props.currentUser.authToken, match.user.id)
.then(results => {
if(results.data.data.length > 0) {
match.convoExists = true
match.convoId = results.data.data[0].id
} else {
match.convoExists = false
}
this.props.addMatchesProfile({matchUserProfiles: match})
...
MatchesActions.js
import {
GET_MATCHES,
ADD_MATCHES_PROFILES,
RESET_MATCHES,
} from './types'
export const addMatchesProfile = ({ matchUserProfiles }) => {
return {
type: ADD_MATCHES_PROFILES,
payload: { matchUserProfiles }
}
}
MatchesReducer.js
import {
GET_MATCHES,
ADD_MATCHES_PROFILES,
RESET_MATCHES,
} from '../actions/types'
const INITIAL_STATE = {
matchUserIds: {},
matchUserIdsLoaded: false,
matchUserProfiles: {},
}
export default (state = INITIAL_STATE, action) => {
switch (action.type) {
case GET_MATCHES:
return {...state, matchUserIds: action.payload, matchUserIdsLoaded: true}
case ADD_MATCHES_PROFILES:
//error occurs here
return {...state, matchUserProfiles: [...state.matchUserProfiles, action.payload]}
case RESET_MATCHES:
return {matchUserIds: INITIAL_STATE, matchUserProfiles: INITIAL_STATE}
default:
return state
}
}