August 2017
Beginner
374 pages
10h 41m
English
Next we create the posts reducer, dealing with creating, editing, and deleting posts.
import { CREATE_POST, EDIT_POST, DELETE_POST } from '../actionTypes'
export default function postsReducer (state = [], action) {
switch (action.type) {
case CREATE_POST: { const { type, post } = action const ts = Date.now() return [ ...state, { ...post, created: ts, updated: ts }, ] } ...Read now
Unlock full access