我试图获取我使用v6 redux-form创建的表单,以便在我的App组件中呈现以在浏览器中显示。但是,我收到以下错误:
Uncaught Error: `mapDispatchToProps` must return an object. Instead received function () {
return computedActions;
}.
我的LoginForm组件:
import React, { Component } from 'react'
import { reduxForm, Field } from 'redux-form'
class LoginForm extends Component {
render() {
return (
<form>
<div>
<label htmlFor="email">Email</label>
<Field
name="email"
component="input"
type="text"
/>
</div>
<div>
<label htmlFor="password">Password</label>
<Field
name="password"
component="input"
type="password"
/>
</div>
<button type="submit">Login</button>
</form>
)
}
}
export default reduxForm({ form: 'login' })(LoginForm)
App.js导入LoginForm组件:
import React from 'react'
import LoginForm from '../containers/LoginForm'
export default () =>
<div>
<LoginForm />
</div>
我的顶级index.js:
import React from 'react'
import ReactDOM from 'react-dom'
import { Provider } from 'react-redux'
import { BrowserRouter, Route } from 'react-router-dom'
import reducers from './reducers'
import configureStore from './store/configureStore'
import App from './components/App'
const store = configureStore()
ReactDOM.render(
<Provider store={store}>
<BrowserRouter>
<App />
</BrowserRouter>
</Provider>,
document.getElementById('root'))
相关依赖项:
"react-dom": "^0.14.3",
"react-redux": "4.0.0",
"react-router-dom": "^4.1.1",
"redux": "^3.0.4",
"redux-form": "^6.6.3"
非常感谢任何对解决方案的洞察力!
答案 0 :(得分:0)
通过将react-redux更新到最新版本5.x来解决问题