Когда я загружаю свое приложение, я получаю это исключение js.Не уверен, почему!
Uncaught (в обещании) TypeError: Невозможно прочитать свойство 'vehicle_full' из неопределенного в ActionCreators.js:?
export function loadPairDataActionCreator(address, refresh, topPartner, bottomPartner) {
return dispatch => fetch(address, returnHeaders())
.then(res => checkLogout(res))
.then(
data => {
// Change primary key from SHA to cName
if (data) {
let nd = [];
for (let p in data) {
const pair = data[p];
let tmp = {};
const pair_ids = Object.keys(pair);
for (let pi of pair_ids) {
tmp[pair[pi].vehicle_full] = pair[pi];
}
nd.push(tmp);
}
data = nd;
store.dispatch(currentPairs(data));
let vehicles = store.getState().vehicles,
keys = Object.keys(vehicles);
for (var i = 0; i < data.length; i++) {
const pair = data[i];
// pair ids
const [vehicle1, vehicle2] = Object.keys(pair);
// Add pairedWith field to each truck in the pair
store.dispatch(
addPairedVehicleActionCreator(
pair[vehicle2].vehicle_full, //<--- error here
vehicle1
))
store.dispatch(
addPairedVehicleActionCreator(
pair[vehicle1].vehicle_full,
vehicle2
))
}
store.dispatch(pairingComplete(true))
}
},
err => dispatch({
type: 'LOAD_PAIR_DATA_FAILURE',
err
})
)
.then(
() => {
if (refresh === "unpair") {
store.dispatch(changePageModeActionCreator({
mode: "READY_TO_UNPAIR",
rowIdentifier: store.getState().pageMode.rowIdentifier
}));
} else if (refresh === "pair") {
store.dispatch(changePageModeActionCreator({
mode: "READY_TO_PAIR",
rowIdentifier: topPartner,
rowIdentifierBottom: bottomPartner
}));
}
}
)
.then(
() => {
store.dispatch(removePairedVehicleActionCreator(topPartner)),
store.dispatch(removePairedVehicleActionCreator(bottomPartner))
}
)
}