Uncaught Error: Actions must be plain objects. Use custom middleware for async actions.....未知のエラー:アクションはプレーンなオブジェクトでなければなりません。非同期アクションにはカスタムミドルウェアを使用します。私はどのように私の店で作成を使用する?
コンポーネントをレンダリングするための私のindex.jsファイル。 Howiは私の店で作成を使用する?
import React from 'react'
import ReactDOM from 'react-dom'
import { Provider } from 'react-redux'
import { Router, Route, browserHistory } from 'react-router'
import { createStore, applyMiddleware } from 'redux'
import thunk from 'redux-thunk'
import AppContainer from './views/App/container'
import './index.scss'
import reducer from './store/reducers'
const createStoreWithMiddleware = applyMiddleware(thunk)(createStore)
const store = createStoreWithMiddleware(reducer)
ReactDOM.render(
<Provider store={store}>
<Router history={ browserHistory }>
<Route path="/" component={ AppContainer }/>
</Router>
</Provider>,
document.getElementById('root')
)
リデューサーファイル:
Uncaught Error: Actions must be plain objects. Use custom middleware for async actions.....
import { combineReducers } from 'redux'
import { routerReducer } from 'react-router-redux'
import phoneVerify from './phoneverify'
import auth from './auth'
const rootReducer = combineReducers({
routing: routerReducer,
isLogin: auth,
phoneVerify
})
export default rootReducer
アクションファイル:
Uncaught Error: Actions must be plain objects. Use custom middleware for async actions.....
import $ from 'jquery'
import { phoneVerify } from '../actions/types'
const verifyPhoneAsync = function (verification) {
return {
type: phoneVerify,
payload: verification
}
}
const verifyPhone = function (phone) {
$.ajax({
url: 'api',
type: 'POST',
data: { mobile: phone },
dataType: 'json',
success: (data) => {
console.log(data)
}
})
}
const verifyOtp = function (phone, otp) {
return (dispatch) => {
$.ajax({
url: 'api',
type: 'POST',
data: { mobile: phone, code: otp, devicetoken: 'nil', devicetype: 'nil' },
dataType: 'json',
success: (data) => {
if (data.success === true) {
localStorage.setItem('MobileNumber', phone)
const varification = data
dispatch(verifyPhoneAsync(varification))
} else {
console.log('rfg')
const varification = data
dispatch(verifyPhoneAsync(varification))
}
}
})
}
}
export { verifyPhone, verifyOtp }
あなたの還元行為を共有する必要があります –