yapi/client/reducer/news/news.js

30 lines
475 B
JavaScript
Raw Normal View History

2017-07-17 12:15:21 +08:00
import {
FETCH_NEWS_DATA,
FETCH_MORE_NEWS
2017-07-17 12:15:21 +08:00
} from '../../constants/action-types.js'
const initialState = {
newsData: []
}
export default (state = initialState, action) => {
switch (action.type) {
case FETCH_NEWS_DATA: {
2017-07-17 12:15:21 +08:00
return {
...state,
newsData: action.payload
};
}
case FETCH_MORE_NEWS: {
state.newsData.push(...action.payload);
return {
...state
}
}
2017-07-17 12:15:21 +08:00
default:
return state;
}
}