-
-
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
Add more checking in SimpleShowLayout to only pass props to react-admin components #3154
Comments
At a quick glance it looks like type checking is tricky due to HOCs and such. I really have no idea how best to do this. Maybe adding something to the supported components similar to The following pattern seems really fragile but since I pretty much always use the
|
Hi, and thanks for your suggestion. As much as possible, we try to avoid inspecting children when cloning them. We've found that it creates many problems when developers wrap a react-admin component inside their own component to customize e.g. styles. So props sanitization is the responsibility of the children, and your first approach is correct. We won't add a check to introduce two different ways to pass props to children, that would be fragile and error prone. So I'm closing this feature request as we won't implement it. |
Fair enough, thanks for the reply. |
I can understand your difficulties. I think it might become easier once we migrate to React Hooks - but that will take months. |
This should be in the documentation. If using react-admin means one has to give up on native html tags or wrap them then I think there is something wrong. |
What you were expecting:
To be able to use non-input components in a
<SimpleShowLayout>
without prop warnings about "React does not recognize thebasePath
prop on a DOM element."What happened instead:
I get warnings when using components like
<Typography>
.Steps to reproduce:
Rough example:
Related code:
I'm fairly new to React still so this may be naive. I used a little workaround to strip props in a div to wrap non-field components, which worked as far as removing warnings, but seems like a workaround rather than a real solutions:
In SimpleShowLayout (https://github.com/marmelab/react-admin/blob/master/packages/ra-ui-materialui/src/detail/SimpleShowLayout.js), I see there is only type checking for strings. I propose only cloning components that need it (fields and inputs?)
Other information:
Environment
The text was updated successfully, but these errors were encountered: