0
votes

I'm stacked. I want to integrate with React-Semantic-UI Component with redux-form. Field components don't handle input. I typed some values from the keyboard and nothing happens, input fields steel empty. Pls someone helps, what I am doing wrong? I find some relevant questions on this topic but nothing helped.

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)
1

1 Answers

1
votes

Fellows, I find the solution to my problem. Then you are using redux, you need to add redux-form reducer in to the app reducers.

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)