动作必须是普通对象

时间:2017-12-29 11:14:44

标签: javascript reactjs react-redux

我正在尝试使用api调用localstorage类型应用程序来创建简单的react-redux应用程序但是当我调用一个操作时它不会更新我的状态甚至也显示此错误。当我需要调用api并从api管理数据时,我知道中间件是必需的。这将像一座桥梁,但我没有调用任何API,为什么我会收到此错误?

这是我的代码



import React from 'react'
import ReactDOM from 'react-dom'
import {Provider} from 'react-redux'
import configureStore from './store/configureStore'
import AppRouter from './routers/Approuter'
import { addReport } from './actions/reportsaction'
import { setTextFilter } from './actions/reportfilters'
import App from './App'
import getvisibilityfilter from './selectors/reportsvisibilty'
import registerServiceWorker from './registerServiceWorker';
const store = configureStore();
console.log(store)
store.dispatch(addReport({patient_name:'Akki Sharma'}));
store.dispatch(setTextFilter({text:'akki'}));
const state = store.getState();
console.log(state)
// const visiblereport = getvisibilityfilter(state.reports, state.filters)
// console.log(visiblereport)


ReactDOM.render( <AppRouter/>, document.getElementById('app'));

ReactDOM.render(<App />, document.getElementById('root'));
registerServiceWorker();
&#13;
&#13;
&#13;

addReport.js

export const addReport = ({
    r_id = 0
    , reg_date = ''
    , reg_no = 0
    , patient_name = ''
    , gender = ''
    , age = 0
    , refer_by = ''
    , test_request = ''
    , report_status = ''
    , total_amt = 0
    , receipt_amt = 0
    , bal_amt = 0
} = {}) => {
    return {
        type: 'ADD_REPORTS'
        , reports: {
            r_id
            , reg_date
            , reg_no
            , patient_name
            , gender
            , age
            , refer_by
            , test_request
            , report_status
            , total_amt
            , receipt_amt
            , bal_amt
        }
    }
}
setTextFilter: export const setTextFilter = (text = '') => {
    return {
        type: 'SET_TEXT_FILTER'
        , text
    }
}

0 个答案:

没有答案