标签: redux-form

如何使用 Redux-form 从复选框中获取值?

您如何将 redux 表单中复选框的默认布尔值更改为您在输入本身上指定的值?

例如,我有一个这样的输入:

<input type="checkbox" value="Pages missing or out of order" {...issue1} />

当 Redux 表单选择它时,它只会给我一个真/假,即使我想要值“页面丢失或乱序”

我可以做这样的事情来到达我需要去的地方,以便在表单提交时,它会提交值“页面丢失或乱序,而不是真/假?

<input type="checkbox" onChange={value => console.log(value.target.value)} value="Pages missing or out of order" />

当我删除 {...issue1} 时,将调用我的自定义 onChange 事件处理程序,但是当我保留 {...issue1} 时,它会被完全忽略。

想法?

reactjs redux redux-form

2
推荐指数
2
解决办法
7153
查看次数

Field组件外部的Redux-form 6.0.0访问错误

在Redux-form v5中,我能够从装饰表单中的任何位置访问"内联"错误(异步验证),如下所示:

const fields = [
  'email'
]

// inside the decorated form
const { email } = this.props.fields

console.log(email.error) // 'the validation error of the 'email' field
Run Code Online (Sandbox Code Playgroud)

如何使用Redux-form 6.0.0+实现相同的功能?

reactjs redux-form

2
推荐指数
1
解决办法
1884
查看次数

Redux-form在OnSubmit处理程序中返回Proxy

我尝试运行示例代码.

<form onSubmit={values => console.log("========>", values)}>
    <div>
      <label htmlFor="firstName">First Nameeee</label>
      <Field name="firstName" component="Input" type="text"/>
    </div>
    <div>
      <label htmlFor="lastName">Last Name</label>
      <Field name="lastName" component="Input" type="text"/>
    </div>
    <div>
      <label htmlFor="email">Email</label>
      <Field name="email" component="Input" type="email"/>
    </div>
    <button type="submit">Submit</button>
  </form>
Run Code Online (Sandbox Code Playgroud)

但是当我处理onSubmit事件时,param值返回一个Proxy而不是一个带有输入值的对象.

//Console.log output
Proxy {dispatchConfig: Object, _targetInst: ReactDOMComponent, _dispatchInstances: ReactDOMComponent, nativeEvent: Event, type: "submit"…}
Run Code Online (Sandbox Code Playgroud)

redux redux-form

2
推荐指数
1
解决办法
1023
查看次数

ReduxForm:在FieldArray中使用formValueSelector用于条件字段不会立即呈现

这个排序的作品,除了附加块显示不出来,当我做出的service_type无线电选择它,只弹出/重新呈现,如果我完成额外的操作,比如添加或删除服地块或更改其他领域.

    import './Register.scss';
    import React, { Component, PropTypes } from 'react';
    import { connect } from 'react-redux';
    import { Field, reduxForm, FieldArray, formValueSelector } from 'redux-form';
    import MenuItem from 'material-ui/MenuItem';
    import { RadioButton } from 'material-ui/RadioButton'
    import {
      TextField,
      SelectField,
      TimePicker,
      RadioButtonGroup
    } from 'redux-form-material-ui';
    import validate from './validate';

    class OnboardPageThree extends Component {
      static propTypes = {
        handleSubmit: PropTypes.func.isRequired,
        previousPage: PropTypes.func.isRequired
      }

      constructor(props, context) {
            super(props, context);
        }

      renderGroups = ({ fields, meta: { touched, error } …
Run Code Online (Sandbox Code Playgroud)

reactjs redux material-ui redux-form

2
推荐指数
1
解决办法
1502
查看次数

如何在Redux表单的文本输入中避免或禁用autoComplete?

我正在使用ReactJS和ReduxJS来构建我的应用程序.

我使用Redux-Form创建了我的表单,并且有很多文本输入,对于其中一个,我使用onkeyDown事件来增加和减少我的文本中的数字

因此,当我单击向上箭头或输入第一个数字时,文本将自动完成,输入上一个日期(历史记录),当我单击另一个向上箭头时会打扰

[提示]我尝试过AutoComplete=off 但没有工作

在此输入图像描述

javascript redux-form react-redux

2
推荐指数
1
解决办法
4716
查看次数

React中的类赋值

目前我正在使用redux-form,现在我必须将我的reduxForm组件连接到我的redux存储.所以,看看文档我必须做的事情如下:

// Decorate with reduxForm(). It will read the initialValues prop provided by connect()
InitializeFromStateForm = reduxForm({
  form: 'initializeFromState'  // a unique identifier for this form
})(InitializeFromStateForm)

// You have to connect() to any reducers that you wish to connect to yourself
InitializeFromStateForm = connect(
  state => ({
    initialValues: state.account.data // pull initial values from account reducer
  }),
  { load: loadAccount }               // bind account loading action creator
)(InitializeFromStateForm)

export default InitializeFromStateForm
Run Code Online (Sandbox Code Playgroud)

我在我的组件中做了类似的事情,但是,eslint …

javascript ecmascript-6 reactjs eslint redux-form

2
推荐指数
1
解决办法
469
查看次数

Redux形式v6 isDirty(和isPristine)选择器在状态更改时不会触发重新渲染

我正在尝试从父组件检测表单状态是否脏,因此,如果表单值已更改,我只能显示一个提交按钮。

初始渲染按预期显示为false,但是更改值不会触发使用新vlaue的重新渲染。

import React from 'react'
import { isDirty } from 'redux-form'
import { connect } from 'react-redux'

<Parent>
  { props.isDirty ? <SubmitButton /> : null }
  <Form {...etc} />
</Parent>

const mapStateToProps = state => ({
  ...
  isDirty: isDirty('myForm')(state),
})

export default connect(mapStateToProps, null)(Parent)
Run Code Online (Sandbox Code Playgroud)

控制台日志记录props.isDirty显示的初始呈现<Parent/> isDirty为false。但是,更改值不会触发<Parent/>使用新值重新呈现。

更新:

经过进一步调查,我认为这是一个错误:

const mapStateToProps = (state) => {
  console.log(isDirty('myForm')(state)
  return {
    ...
    isDirty: isDirty('myForm')(state),
  }
Run Code Online (Sandbox Code Playgroud)

此处,更改表单值会mapStateToProps按预期触发,但isDirty始终为false。

reactjs immutable.js react-native redux redux-form

2
推荐指数
1
解决办法
1559
查看次数

react-redux上传文件错误

我尝试使用redux-form在react-redux上实现文件上传,但是控制台中有警告和异常:

警告:ConnectedField正在更改要控制的类型文件的不受控制的输入。输入元素不应从不受控制切换为受控制(反之亦然)。确定在组件的使用寿命期间使用受控或不受控制的输入元素。

bundle.js:37467 Uncaught DOMException: Failed to set the 'value' property on 
'HTMLInputElement': This input element accepts a filename, which may only be 
programmatically set to the empty string.
        at Object.updateWrapper (http://localhost:8080/dist/bundle.js:37467:20)
        at ReactDOMComponent.updateComponent (http://localhost:8080/dist/bundle.js:36891:23)
        at ReactDOMComponent.receiveComponent (http://localhost:8080/dist/bundle.js:36846:10)
        at Object.receiveComponent (http://localhost:8080/dist/bundle.js:6247:22)
        at ReactCompositeComponentWrapper._updateRenderedComponent (http://localhost:8080/dist/bundle.js:35859:23)
        at ReactCompositeComponentWrapper._performComponentUpdate (http://localhost:8080/dist/bundle.js:35829:10)
        at ReactCompositeComponentWrapper.updateComponent (http://localhost:8080/dist/bundle.js:35750:12)
        at ReactCompositeComponentWrapper.receiveComponent (http://localhost:8080/dist/bundle.js:35652:10)
        at Object.receiveComponent (http://localhost:8080/dist/bundle.js:6247:22)
        at ReactCompositeComponentWrapper._updateRenderedComponent (http://localhost:8080/dist/bundle.js:35859:23)
Run Code Online (Sandbox Code Playgroud)

这是我组件的代码:

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

class UploadFileForm extends Component {

  onFormSubmit(data) {
    console.log(data);
  };

  render() { …
Run Code Online (Sandbox Code Playgroud)

javascript redux-form react-redux react-redux-form

2
推荐指数
1
解决办法
2727
查看次数

如何在nativebase中处理Form的onSubmit函数?

我想在nativebase中使用redux-form,但它的功能与在Web中使用的功能不同。我不认为我的onSubmit回调没有被调用,我也不知道为什么。

import React, { Component } from 'react';
import { reduxForm, Field } from 'redux-form';
import {
  Container,
  Content,
  Item,
  Input,
  Button,
  Form,
  Label,
  Text,
  Icon
} from 'native-base';

import * as actions from '../actions';

class Signin extends Component {
  handleFormSubmit({ username, password }) {
    this.props.userSignIn({ username, password });
  }

  renderUsername() {
    return (
      <Item floatingLabel>
        <Icon name="ios-person" />
        <Label>Username</Label>
        <Input autoCorrect={false} autoCapitalize="none"/>
      </Item>
    );
  }

  renderPassword() {
    return (
      <Item floatingLabel>
        <Icon name="ios-lock" />
        <Label>Password</Label>
        <Input secureTextEntry={true} …
Run Code Online (Sandbox Code Playgroud)

react-native redux-form native-base

2
推荐指数
1
解决办法
2577
查看次数

使用谓词选项过滤redux-logger中的redux-form操作

谁能提供有关Redux-Logger过滤操作的提示?我正在尝试过滤@@redux-form/BLUR来自Redux Form的内容。

根据Redux Logger食谱( https://github.com/evgenyrodionov/redux-logger#log-everything-except-actions-with-certain-type)

Log everything except actions with certain type

createLogger({
  predicate: (getState, action) => action.type !== AUTH_REMOVE_TOKEN
});
Run Code Online (Sandbox Code Playgroud)

基于上面引用的方法,我希望提供一条语句,该语句的格式类似,并返回false。我正在记录成功通过折叠选项的记录,因此我不会怀疑我在applyMiddlewear()中做错了什么。

predicate:(getState, action) => action.type !== @@redux-form/FOCUS || @@redux-form/BLUR || @@redux-form/FOCUS
Run Code Online (Sandbox Code Playgroud)

redux redux-form

2
推荐指数
1
解决办法
902
查看次数