简体   繁体   English

用于kendo-react-ui输入错误的Redux表单包装器

[英]Redux Form wrapper for kendo-react-ui Input error

I am using react-kendo-ui. 我正在使用react-kendo-ui。 I want to wrap Input from @progress/kendo-react-inputs to use it with ReduxForm. 我想从@ progress / kendo-react-inputs包装输入,以将其与ReduxForm一起使用。 Please find my code below: 请在下面找到我的代码:

import React from 'react'
import { Input } from '@progress/kendo-react-inputs';

const InputText = ({ input, label, type, meta: { touched, error } }) => (
    <div>
        <label>{label}</label>
        <div>
            <Input {...input} type={type} placeholder={label} />
            {touched && error && <span>{error}</span>}
        </div>
    </div>
)

export default InputText

Call the InputText from another component as below: 从另一个组件调用InputText,如下所示:

import React from 'react';
import { Field, reduxForm } from 'redux-form';
import { Input } from '@progress/kendo-react-inputs';
import InputText from './input-text';

const validateNotEmpty = value => !value ? 'Must enter a value' : null;

const onSubmit = (values) => {
    console.log(values);
}

const AddLoc= ({ handleSubmit }) => (
    <form onSubmit={handleSubmit}>
        <div>
            <Field
                label="Address"
                name="address"
                component={InputText}
                validate={validateNotEmpty}
            />
        </div>
        <button type="submit">Submit</button>
    </form>
)

export default reduxForm({
    form: 'AddLoc'
})(AddLoc)

But while typing inside the input text it keeps giving the following error/warning: 但是,在输入文本中键入内容时,它始终会给出以下错误/警告:

Warning: This synthetic event is reused for performance reasons. If you're seeing this, you're accessing the property `nativeEvent` on a released/nullified synthetic event. This is set to null. If you must keep the original synthetic event around, use event.persist().

在此处输入图片说明

While typing inside the input text automatically outputs [object Object] . 在内部输入时,输入文本自动输出[object Object] Please check the image above. 请检查上面的图片。 Could anyone please let me know what is causing the error. 任何人都可以让我知道导致错误的原因。

Thanks 谢谢

The reduxForm works only with pure DOM <input /> . reduxForm仅适用于纯DOM <input /> Internally it clones the elements search the children and then attaches the onChange dynamically. 在内部,它会克隆搜索子元素的元素,然后动态附加onChange So it will not work with the Input and the NumericTextBox from the @progress/kendo-react-inputs package. 因此,它NumericTextBox用于@progress/kendo-react-inputs NumericTextBox @progress/kendo-react-inputs包中的InputNumericTextBox This statement is based on the official kendo documentation about integrating with the redux-form. 该声明基于有关与redux-form集成的官方kendo文档

The same author of the redux-form have fork of it called react-final-form which could be used on any component that have Value and onChange props. redux-form的同一作者将其叉称为react-final-form ,可用于具有ValueonChange道具的任何组件。 By our tests it works with the components from @progress/kendo-react-inputs and @progress/kendo-react-dropdowns packages. 通过我们的测试,它可以与@progress/kendo-react-inputs@progress/kendo-react-dropdowns包中的组件一起使用。 It looks kendo already have an example using final-form in their integration section . 看起来kendo的集成部分中已经有一个使用final-form的示例。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM