Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/reactjs/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript Redux表单未采用任何值_Javascript_Reactjs_Redux_React Redux_Redux Form - Fatal编程技术网

Javascript Redux表单未采用任何值

Javascript Redux表单未采用任何值,javascript,reactjs,redux,react-redux,redux-form,Javascript,Reactjs,Redux,React Redux,Redux Form,我一直在尝试使用redux表单创建一个新表单。我的输入表单没有接受任何值 我的代码是: import React, { Component } from "react" import { Field, reduxForm } from "redux-form" class BranchForm extends Component { textFieldComponent = ({ input }) => { console.log(input) return <

我一直在尝试使用redux表单创建一个新表单。我的输入表单没有接受任何值

我的代码是:

import React, { Component } from "react"
import { Field, reduxForm } from "redux-form"

class BranchForm extends Component {
  textFieldComponent = ({ input }) => {
    console.log(input)
    return <input value={input.value} onChange={input.onChange} />
  }

  render() {
    return (
      <form >
        <Field
          name="Branch"
          label="Enter Branch"
          component={this.textFieldComponent}
        ></Field>
      </form>
    )
  }
}

export default reduxForm({ form: "branchForm" })(BranchForm)
这是我整个项目的index.js,我也使用了开发工具

import React from "react"
import ReactDOM from "react-dom"
import Thunk from "redux-thunk"
import { createStore, applyMiddleware, compose } from "redux"
import { Provider } from "react-redux"

import App from "./components/App"
import reducers from "./Reducers"

const composeEnhancers = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose
const store = createStore(reducers, composeEnhancers(applyMiddleware(Thunk)))

const rootElement = document.getElementById("root")
ReactDOM.render(
  <Provider store={store}>
    <App />
  </Provider>,
  rootElement
)
从“React”导入React
从“react dom”导入react dom
从“redux Thunk”导入Thunk
从“redux”导入{createStore,applyMiddleware,compose}
从“react redux”导入{Provider}
从“/components/App”导入应用程序
从“/还原程序”导入还原程序
const composeinhancers=window.\uuu REDUX\u DEVTOOLS\u EXTENSION\u COMPOSE\uu124; | COMPOSE
const store=createStore(还原器、复合器(applyMiddleware(Thunk)))
const rootElement=document.getElementById(“根”)
ReactDOM.render(
,
根元素
)

问题在于您没有为this.textFieldComponent函数提供任何参数。 你可以这样试试

import React, { Component } from "react"
import { Field, reduxForm } from "redux-form"

    class BranchForm extends Component {
      textFieldComponent = ({ input }) => {
        console.log(input)
        return <input value={input.value} onChange={input.onChange} />
      }

      render() {
        const input= {
            value: this.props.value,
            onChange: this.props.onChange
        }
        return (
          <form >
            <Field
              name="Branch"
              label="Enter Branch"
              component={this.textFieldComponent(input)}
            ></Field>
          </form>
        )
      }
    }

    export default reduxForm({ form: "branchForm" })(BranchForm)
import React,{Component}来自“React”
从“redux表单”导入{Field,reduxForm}
类BranchForm扩展组件{
textFieldComponent=({input})=>{
console.log(输入)
回来
}
render(){
常量输入={
value:this.props.value,
onChange:this.props.onChange
}
返回(
)
}
}
导出默认reduxForm({form:“branchForm”})(branchForm)

谢谢你对人们的帮助,我犯了一个非常愚蠢的错误


解决方案是在导出默认语句中分支表单的最后一行,我在导出时给出了表单,而不是表单。

我尝试给出component=“input”但它不起作用是的,我连接了它。我刚刚添加了减速机和索引页的代码,请验证。老实说,我不能确定出了什么问题;(我找到了解决方案,请检查,但错误是愚蠢的。你怎么能把输入作为一个参数呢?上面的答案是完全错误的
import React, { Component } from "react"
import { Field, reduxForm } from "redux-form"

    class BranchForm extends Component {
      textFieldComponent = ({ input }) => {
        console.log(input)
        return <input value={input.value} onChange={input.onChange} />
      }

      render() {
        const input= {
            value: this.props.value,
            onChange: this.props.onChange
        }
        return (
          <form >
            <Field
              name="Branch"
              label="Enter Branch"
              component={this.textFieldComponent(input)}
            ></Field>
          </form>
        )
      }
    }

    export default reduxForm({ form: "branchForm" })(BranchForm)