用于静态管理的包装组件

2024-04-08

我想创建一个新组件,其中包含Inputs and Fields from aor并用在<SimpleForm> and <TabbedForm>如下:

const WrapperComp = () => {
  return (
    <div>
      <TextFieldLabel muiTheme={muiTheme}>Title Example</TextFieldLabel>,
      <TextInput source="status"/>,
      <TextField source="status"/>
    </div>
  )
} 

<SimpleForm>
  <WrapperComp />
</SimpleForm>

但我得到Uncaught Error: The TextInput component wasn't called within a redux-form <Field>. Did you decorate it and forget to add the addField prop to your component?.

任何帮助,将不胜感激。谢谢!


你需要使用Field从 redux-form 来装饰你的 AOR 输入并使用 AOR 中的 TextField 并传递{...props}正如所指出的库纳尔帕里克 https://stackoverflow.com/users/6284861/kunal-pareek

import React from 'react';
import {
    LongTextInput,
    ImageField,
    ImageInput,
    TextField
} from 'admin-on-rest';
import { Field } from 'redux-form';


const CustomGroupComp = (props) => (
    <div>
        <TextField source="status" {...props} />
        <Field name="staffComment" component={LongTextInput} label="staffComment" {...props}  />
        <Field name="adminComment" component={LongTextInput}  label="resources.faults.fields.adminComment" {...props} />
        <Field multiple name="fileA" component={ImageInput} accept="image/*">
            <ImageField source="path" title="title"/>
        </Field>
    </div>
);

export default CustomGroupComp;
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

用于静态管理的包装组件 的相关文章

随机推荐