August 2017
Beginner
374 pages
10h 41m
English
This reducer function is quite simple; it simply sets and clears the filter value, which is set to false (show all posts) by default.
Create a new src/reducers/filter.js file with the following contents:
import { SET_FILTER, CLEAR_FILTER } from '../actionTypes'
export default function filterReducer (state = false, action) {
switch (action.type) {
case SET_FILTER:
return action.filter
case CLEAR_FILTER:
return false
default:
return state
}
}
Read now
Unlock full access