В настоящее время я изучаю мясо и картофель реактивного редукса.Я регистрировал состояние объекта из редуктора.Но я вижу эти узлы 1: a, 2: b и т. Д. Для чего они нужны?
Это мой код редуктора, и я просто вызываю API recipepuppy
import { MAKE_REQUEST, LOAD_SEARCH_RESULTS, SEARCH_FAILED } from "../../constants/actionTypes";
const initialState = {
isRequesting: true,
searchTerm: '',
searchFailed: false,
searchSuccessful: false,
searchResults: []
};
const rootReducer = (state = initialState, action) => {
console.log("Original state" + state);
switch (action.type) {
case MAKE_REQUEST:
let requestState = Object.assign({}, state, action.searchTerm, { isRequesting: true });
console.log(requestState);
return requestState;
case LOAD_SEARCH_RESULTS:
var results = action.searchResults.map(({ thumbnail, title, href }) => { return { thumbnail, title, href } });
let searchResultState = Object.assign({}, state, { isRequesting: false, searchSuccessful: true, searchFailed: false, searchResults: results });
console.log(searchResultState);
return searchResultState;
case SEARCH_FAILED:
let searchFailState = Object.assign({}, state, { isRequesting: false, searchSuccessful: false, searchFailed: true, searchResults: [] });
console.log(searchFailState);
return searchFailState;
default:
return state;
}
}
export default rootReducer;