-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(reducers): use 'combineReducers'
make 'searchTerm' reducer keep its own state
- Loading branch information
1 parent
e5f6bba
commit 3de47cb
Showing
3 changed files
with
32 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,10 @@ | ||
import { SET_SEARCH_TERM } from '../constants/ActionTypes'; | ||
import setSearchTerm from './setSearchTerm'; | ||
/** | ||
* @module reducers | ||
*/ | ||
|
||
const initialState = { | ||
searchTerm: '' | ||
}; | ||
import { combineReducers } from 'redux'; | ||
import searchTerm from './searchTerm'; | ||
|
||
const rootReducer = (state = initialState, action) => { | ||
switch (action.type) { | ||
|
||
case SET_SEARCH_TERM: | ||
return setSearchTerm(state, action); | ||
|
||
default: | ||
return state; | ||
} | ||
}; | ||
|
||
export default rootReducer; | ||
export default combineReducers({ | ||
searchTerm | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/** | ||
* @module reducers/searchTerm | ||
*/ | ||
|
||
import { SET_SEARCH_TERM } from '../constants/ActionTypes'; | ||
|
||
/** | ||
* | ||
* @param state | ||
* @param action | ||
* @return {*} | ||
*/ | ||
export default function searchTerm(state = '', action) { | ||
|
||
switch (action.type) { | ||
|
||
case SET_SEARCH_TERM: | ||
return action.searchTerm; | ||
|
||
default: | ||
return state; | ||
} | ||
|
||
} |
This file was deleted.
Oops, something went wrong.