[英]Redux Form and Semantic UI, handle input onChange
我堆积了。 我想与带有redux-form的 React-Semantic-UI组件集成。 字段组件不处理输入。 我从键盘上键入了一些值,但没有任何反应,输入字段为空。 请有人帮忙,我做错了什么? 我发现了与此主题相关的一些问题,但没有帮助。
import React, { Component } from 'react';
import { Field, reduxForm } from 'redux-form';
import { Button, Form, Message, Progress, Checkbox } from 'semantic-ui-react';
const renderField = ({
label,
input,
name,
placeholder,
type,
meta: { touched, error, warning }
}) => (
<Form.Input required inline {...input} value={input.value} name={name} onChange={(param, {value}) => input.onChange(value)} label={label} placeholder={placeholder} />
)
const Registration = props => {
const { handleSubmit, pristine, reset, submitting } = props
return (
<Form loading={false} onSubmit={handleSubmit}>
<Field
name="name"
type="text"
component={renderField}
label="Имя"
placeholder="введите ваше имя"
/>
<Field
name="email"
type="text"
component={renderField}
label="Email"
placeholder="введите действующую почту"
/>
<Field
name="password"
type="password"
component={renderField}
label="Password"
placeholder="придумайте пароль"
/>
<Field
name="confrim"
type="Confirm"
component={renderField}
label="Имя"
placeholder="повторите ваш пароль"
/>
<Form.Field>
<Checkbox name="agree" label='I agree to the Terms and Conditions' />
</Form.Field>
<Message
success
header='Form Completed'
content="You're all signed up for the newsletter"
/>
<Progress color="red" percent={100} />
<Button disabled={!pristine} type="submit">Ок</Button>
</Form>
)
}
export default reduxForm(
{form: 'registration'}
)(Registration)
研究员,我找到了解决问题的办法。 然后,您正在使用redux ,您需要将redux-formredizer添加到应用程序缩减器中。
import { createStore, combineReducers } from 'redux'
import { reducer as formReducer } from 'redux-form'
const reducers = {
// your reducer goes here
form: formReducer // All form data will store here in form state
}
const reducer = combineReducers(reducers)
const store = createStore(reducer)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.