如何使用外部 ReferenceField 的结果值
const MyComponent = (props) => {
//how I can use here user.fullName?
//console.log(user.fullName)
return (
<ReferenceField
reference="users"
source="userId"
record={props.record}
link={false}
>
<UserNameField />
</ReferenceField>
);
};
const UserNameField = () => {
return (
<FunctionField<User>
render={(user) => (user ? `${user.fullName ?? ''}` : '')}
/>
);
};
我如何在 ReferenceField
之外使用 user.fullName
?
const MyComponent = (props) => {
//how I can use here user.fullName?
//console.log(user.fullName)
return (
<ReferenceField
reference="users"
source="userId"
record={props.record}
link={false}
>
<UserNameField />
</ReferenceField>
);
};
const UserNameField = () => {
return (
<FunctionField<User>
render={(user) => (user ? `${user.fullName ?? ''}` : '')}
/>
);
};
how can I use user.fullName
somewere outside of ReferenceField
?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
ReferenceField
通过在内部调用应用datapProvider.getMany
方法并使其可供其子级使用来获取users
数据。如果你想在外面得到同样的东西,你就必须自己索要数据
The
ReferenceField
gets theusers
data by internally calling the appdatapProvider.getMany
method and making it available for its children.If you want the same outside of it, you are going to have to ask for the data yourself