-
-
Notifications
You must be signed in to change notification settings - Fork 5.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support <ReferenceOneField emptyContent>
#10450
base: next
Are you sure you want to change the base?
Conversation
}); | ||
|
||
export const EmptyText = () => ( | ||
<AdminContext dataProvider={dataProvider} i18nProvider={i18nProvider}> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you wrap this story inside a TestMemoryRouter
?
const renderEmptyItemOption = useCallback(() => { | ||
return typeof emptyText === 'string' ? ( | ||
<Typography component="span" variant="body2"> | ||
{emptyText && translate(emptyText, { _: emptyText })} | ||
</Typography> | ||
) : emptyText ? ( | ||
emptyText | ||
) : null; | ||
}, [emptyText, translate]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don't need all this. Just add the useCallback
function content directly where you currently call it
Closes #10185
Problem
We cannot pass a ReactNode to
ReferenceOneField
when we don't have any record, we can only pass text.Solution
Support
ReactElement
in<ReferenceOneField emptyText>
How To Test
https://react-admin-storybook-gzj7x0njd-marmelab.vercel.app/?path=/story/ra-ui-materialui-fields-referenceonefield--empty-text
Additional Checks
master
for a bugfix, ornext
for a feature