gpt4 book ai didi

javascript - v6 redux-form,reduxForm() mapDispatchToProps 返回错误

转载 作者:行者123 更新时间:2023-11-28 04:43:45 25 4
gpt4 key购买 nike

我正在尝试获取使用 v6 redux-form 创建的表单,以在我的应用程序组件中呈现以在浏览器中显示。但是,我收到以下错误:

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"

任何对解决方案的见解都将不胜感激!

最佳答案

通过将react-redux更新到最新版本5.x解决了问题

关于javascript - v6 redux-form,reduxForm() mapDispatchToProps 返回错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43566909/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com