Skip to content

Commit

Permalink
Clean up reducer code a bit
Browse files Browse the repository at this point in the history
  • Loading branch information
taion committed Nov 3, 2016
1 parent 28e4852 commit c554f47
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/foundReducer.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
import ActionTypes from './ActionTypes';

export default function foundReducer(state = null, action) {
switch (action.type) {
const { type, payload } = action;

switch (type) {
case ActionTypes.UPDATE_MATCH:
// For the initial match, set resolvedMatch too. There's no previous
// result to keep rendered, plus this simplifies server rendering.
return {
match: action.payload,
resolvedMatch: state ? state.resolvedMatch : action.payload,
match: payload,
resolvedMatch: state ? state.resolvedMatch : payload,
};
case ActionTypes.RESOLVE_MATCH:
// It doesn't make sense to resolve a match if there wasn't already an
// unresolved match.
return state && {
match: state.match,
resolvedMatch: action.payload,
resolvedMatch: payload,
};
default:
return state;
Expand Down

0 comments on commit c554f47

Please sign in to comment.