¿Cómo agrego elementos en mi matriz arr[]
de estado redux en reductor? Yo estoy haciendo esto-
import {ADD_ITEM} from '../Actions/UserActions'
const initialUserState = {
arr:[]
}
export default function userState(state = initialUserState, action)
{
console.log(arr);
switch (action.type)
{
case ADD_ITEM:
return {
...state,
arr: state.arr.push([action.newItem])
}
default:
return state
}
}
react-native
redux
react-redux
coderzzz18
fuente
fuente
arr: [...state.arr, why here?]
[action.newItem, ...state.arr]
insertaría el elemento en la primera posición.