There is an action :

 export const setCurrentFullData = (market, type, odd)=> dispatch => { dispatch({ type: 'ADD_FULL_DATA_SUCCESS', payload: { market: market, type:type, odd: odd } }); }; 

And reducer :

 const initialState = []; export default function currentFullData(state = initialState, action) { if (action.type === 'ADD_FULL_DATA_SUCCESS') { state.push(action.payload); return state; } return state; } 

For some reason, the first return does not return anything, if you change the state to action.payload then the object is returned

    2 answers 2

    Instead of state.push(action.payload) you need to write return [...state, action.payload] state in redaks cannot be modified, you must always return a new object.

      To add several elements to the reducer , use the concut function:

       const initialState = []; export default function currentFullData(state = initialState, action) { if (action.type === 'ADD_FULL_DATA_SUCCESS') { let newBet = state.concat([action.payload]); return newBet; } return state; }