question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ReferenceField always display

See original GitHub issue

Hello, thanks you for your project. I think there is a bug with ReferenceField. When I use ReferenceField and the source is null, the loading appears but remains indefinitely. I have the impression that the field does not check before if the source is not null.

capture d ecran 2018-10-04 a 15 34 00

I was able to correct this by doing it like that but I think there must be a better solution:

const ConditionalReferenceField = ({ record, ...rest }) =>
  record && record[rest.source] ? (
    <ReferenceField {...rest}>
      <TextField source="name" />
    </ReferenceField>
  ) : null;
  • React-admin version: 2.3.3
  • Last version that did not exhibit the issue (if applicable): no applicable
  • React version: 16.5.2
  • Browser: Chrome
  • Stack trace (in case of a JS error): no

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:10 (10 by maintainers)

github_iconTop GitHub Comments

8reactions
TomJannescommented, Oct 4, 2018

I think you can use the allowEmpty={true} attribute on the ReferenceField

0reactions
fzaninottocommented, Aug 22, 2019

Refixed in #3550

Read more comments on GitHub >

github_iconTop Results From Across the Web

Reference field is not showing the expected display value ...
A reference field is not showing the expected display value when selected or it appears blank. Cause. It could be due to one...
Read more >
View title is always displayed if the extra setting is hidden
View title is always displayed if the extra setting is hidden. Reviewed & tested by the community. Project: Views Reference Field. Version:.
Read more >
Add a 'target' field to <ReferenceField> #5581 - GitHub
I want to use a ReferenceField, to lookup a (single) resource based on a ... the target resource exists or not (so it's...
Read more >
React-admin - Field Components - Marmelab
Tip: Always check the record is defined before inspecting its properties, as react-admin may display the Show view before fetching the record from...
Read more >
Custom reference field apps in the Contentful App Framework
Ever wondered how to use the Contentful App Framework to create a custom reference field app? In this post, we'll show you how....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found