-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
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
[Table] Rendering a table fails silently when using unsupported child element #4726
Comments
Similar issue here: I have a component that renders
(where EDIT: I tried a workaround by assigning |
I've just been bitten by this bug too. I have spent most of the afternoon in tracing this issue. const {muiName} = child.type;
if (muiName === 'TableBody') {
tBody = this.createTableBody(child);
} else if (muiName === 'TableHeader') {
tHead = this.createTableHeader(child);
} else if (muiName === 'TableFooter') {
tFoot = this.createTableFooter(child);
} Apparently someone made a too strong assumption about A possible (albeit a bit ugly) workaround is to write one's code a bit differently... <Table>
<MyTableHeader/>
<MyTableBody/>
</Table> one can write it like this: <Table>
{MyTableHeader()}
{MyTableBody()}
</Table> |
We have been porting the component on the v1-beta branch. We reimplemented it from the ground-up. While we haven't tested it, I think that the issue is most likely fixed on that branch. Hence, I'm closing it. |
Problem description
If you include a child of the
Table
component that is notTableHeader
,TableBody
, orTableFooter
, the child component is never rendered but no error is thrown. Failing silently (or strictly speaking, ignoring the child silently) is an anti-pattern and resulted in several hours of frustration in trying to root cause why the components weren't rendering.Possible solutions
render
method for theTable
component, throw an exception if the component is not supported.TableHeader
,TableBody
, orTableFooter
. After all, there are no such restrictions thatTableBody
's children must beTableRows
, and it enforces long/complex components instead of being able to break down in to small parts.Steps to reproduce
Breakdown the components of your table into subcomponents that wrap the MaterialUi subcomponents:
The render methods of
MyTableHeader
andMyTableBody
are never executed, and no errors are logged to the console.Versions
The text was updated successfully, but these errors were encountered: