Devendra174's picture
Upload folder using huggingface_hub
f5071ca verified
raw
history blame contribute delete
579 Bytes
import {
RECEIVE_POST_PAYLOAD,
RECEIVE_POST,
REMOVE_POST
} from '../actions/post_actions';
const postsReducer = (state = {}, action) => {
Object.freeze(state);
const newState = Object.assign({}, state);
switch (action.type) {
case RECEIVE_POST_PAYLOAD:
return Object.assign(newState, action.postPayload.posts);
case RECEIVE_POST:
return Object.assign(newState, {[action.post.id]: action.post})
case REMOVE_POST:
delete newState[action.postId];
return newState;
default:
return state
}
};
export default postsReducer;