I really don't understand how to add data to my store, nothing complicated I don't understand, I looked at a lot of tutorials and resources but nothing works, the best I have is null in my store with the current userReducer.
My store :
My userReducer :
import {GET_USER, GET_USERS, ADD_USER} from "../actions/userAction";
export default function userReducer(state = {}, action) {
switch (action.type) {
case GET_USER:
return action.payload
case GET_USERS:
return action.payload
case ADD_USER:
return [
...state,
action.payload
]
default :
return state
}
}
Thank you very much for your help
---EDIT---
case GET_USERS:
return {
users: action.payload
}
case ADD_USER:
return {
users: [
...state.users,
action.payload
]
}
