react-admin 组件的问题

Problems with react-admin components

我正在尝试在 Edit 中使用 TabbedShowLayout,但是这个 return 错误与缺少的道具有关:

print of the error

这是我的代码:

export const BarberEdit = (props) => {
  const [id, setId] = useState(props.id);
  const [name, setName] = useState("");
  const [phone, setPhone] = useState("");
  const [birthday, setBirthday] = useState(Date);
  const [transport, setTransport] = useState("");
  const [email, setEmail] = useState("");

  function handleSubmit() {
    console.log("alguma coisa.");
  }

  return (
    <Edit {...props} title={<BarberEditTitle />}>
      <TabbedShowLayout>
        <Tab label="Perfil">
          <SimpleForm submitOnEnter={false}>
            <TextInput source="name" />
            <TextInput source="phone" />
            <DateInput source="birthday" />
            <TextInput source="transport" />
            <TextInput source="email" />
          </SimpleForm>
        </Tab>

        <Tab label="Endereço">
          <ReferenceManyField
            label=""
            reference="barbers_addresses"
            target="barberId"
          >
            <Datagrid>
              <TextField source="street" label="Rua" />
              <TextField source="city" label="Cidade" />
              <TextField source="district" label="Bairro" />
            </Datagrid>
          </ReferenceManyField>
        </Tab>
      </TabbedShowLayout>
    </Edit>
  );
};

稍微阅读了 react-admin 文档,我发现 SimpleForm 有两个继承属性。

提前致谢!

对于编辑和创建布局,您应该使用 TabbedForm,而不是 TabbedShowLayout, 另外,不需要使用 SimpleForm 作为 Tab child,您可以将 submitOnEnter 直接传递给 TabbedForm

export const BarberEdit = (props) => {
  const [id, setId] = useState(props.id);
  const [name, setName] = useState("");
  const [phone, setPhone] = useState("");
  const [birthday, setBirthday] = useState(Date);
  const [transport, setTransport] = useState("");
  const [email, setEmail] = useState("");

  function handleSubmit() {
    console.log("alguma coisa.");
  }

  return (
    <Edit {...props} title={<BarberEditTitle />}>
      <TabbedForm submitOnEnter={false}>
        <FormTab label="Perfil">
            <TextInput source="name" />
            <TextInput source="phone" />
            <DateInput source="birthday" />
            <TextInput source="transport" />
            <TextInput source="email" />
        </FormTab>

        <FormTab label="Endereço">
          <ReferenceManyField
            label=""
            reference="barbers_addresses"
            target="barberId"
          >
            <Datagrid>
              <TextField source="street" label="Rua" />
              <TextField source="city" label="Cidade" />
              <TextField source="district" label="Bairro" />
            </Datagrid>
          </ReferenceManyField>
        </FormTab>
      </TabbedForm>
    </Edit>
  );
};