Conversation
| <RecordField source="title" empty="resources.books.fields.title.missing" /> | ||
| ``` | ||
|
|
||
| If you use the `render` prop, you can even use a React element as `empty` value. |
There was a problem hiding this comment.
This comes as a surprise to me. Why require a render prop to support a React element? To me, you should be able to use a React element in all cases. You can simply render empty (when it's a React element) instead of the provided children/field/render when the value is empty.
There was a problem hiding this comment.
Except TextField and other fields don't use the empty, they use emptyText, and it can only be a string. This may change in the future, but until then we're blocked with allowing React Element in empty only when using the render prop.
There was a problem hiding this comment.
I think it's no big deal for now, so this is non-blocking. But just for the record, my idea was that RecordField would be responsible for rendering the empty element, not TextField, nor any other component passed as children or field.
Co-authored-by: Jean-Baptiste Kaiser <jb@marmelab.com>
Co-authored-by: Jean-Baptiste Kaiser <jb@marmelab.com>
Problem
<SimpleShowLayout>uses child inspection to decorate its children with labels.This isn't robust, as you just need to wrap a child component to break this decoration:
Solution
Invert the responsibilities : it's no longer the layout's role to add a label, but the field's.
Provide a new component to render a field and its label,
RecordField:How To Test
Use the fields/RecordField story
Additional Checks
masterfor a bugfix or a documentation fix, ornextfor a feature