immutable 好像对第二个 json 文件没起作用。点击更多内容后报错 item.get is not a function.
// actionCreators.js
import axios from ‘axios’;
import *as constants from ‘./constants’;
import { fromJS } from ‘immutable’;
const changeHomeData = (result) => ({
type: constants.CHANGE_HOME_DATA,
topicList: result.topicList,
articalList: result.articalList,
recommendList: result.recommendList
})
const addHomeList = (list) => ({
type: constants.ADD_HOME_DATA,
list: fromJS(list)
})
export const getHomeInfo = () => {
return (dispatch) => {
axios.get(’/api/home.json’).then((res) => {
const result = res.data.data;
dispatch(changeHomeData(result));
})
}
}
export const getMoreList = () => {
return (dispatch) => {
console.log(‘click’)
axios.get(’/api/homelist.json’).then((res) => {
const result = res.data.data;
// console.log(result);
dispatch(addHomeList(result));
})
}
}
-------------------------
// list.js
class List extends Component {
render() {
const { list, getMoreList } = this.props;
return (
{item.get(‘desc’)}
// 报错提示