首页 > 解决方案 > 为什么我会收到“关联的参考资料似乎不再可用”?

问题描述

我在这里解释了整个问题https://github.com/marmelab/react-admin/issues/5142。但就 stackoverflow 社区更活跃而言,我在这里也提到了这个问题。

请解释一下,为什么这个示例代码可以正常工作

  <ReferenceInput label={"Specification"} perPage={20} source={"specificationName"}
                                    reference={ResourceNames.SPECIFICATIONS}>
                        <SelectInput optionText={"name"}/>
   </ReferenceInput>

虽然此代码显示"Associated reference no longer appears to be available"错误消息。

  <ReferenceInput label={"Specification"} perPage={20} source={"specificationName"}
                                    reference={ResourceNames.SPECIFICATIONS}>
                        <SelectInput optionText={"name"} optionValue={"name"} />
   </ReferenceInput>

上述示例之间的唯一区别是optionValue传递给SelectInput. 它出什么问题了?我不希望 mySelectInput用作ID值...该optionValue属性与上述错误消息有何关系?

请帮忙!先感谢您

标签: react-admin

解决方案


我找到了解决方案。React-Admin 需要id用于资源识别。

但是,如果您需要为您的资源自定义标识符,请查看下面的文章

请参阅https://marmelab.com/react-admin/FAQ.html#can-i-have-custom-identifiersprimary-keys-for-my-resources


推荐阅读