Closed jstoeffler closed 1 week ago
Hello @jstoeffler,
Nice catch :+1:, reproduced in this Stackblitz (by clicking on the "click" button in the Post create page)
You have to wrap your component in a forwardRef
:
const CustomAlertComponent = React.forwardRef((props, ref) => {
return (
<Alert ref={ref} severity="error">
This is a custom error
</Alert>
);
});
This is required by Material UI
What you were expecting:
I have a custom
mutationOptions
withonError
on aCreate
form that displays a customAlert
component:This works fine:
https://github.com/marmelab/react-admin/assets/3008836/e40066ec-a636-47c8-a98b-f9fe7cc1c963
I would expect to be able to extract this alert's JSX to do something like:
And it should work the same.
What happened instead:
I get a white page instead of seeing the error, it breaks the app and there is no error log:
https://github.com/marmelab/react-admin/assets/3008836/6685219b-ad5d-41c7-9d83-126c48129d1c
Steps to reproduce:
npm run dev
Related code:
Other information:
Environment