Material-ui: Warning when subheader is not set in CardHeader component

Created on 19 Dec 2017  ·  10Comments  ·  Source: mui-org/material-ui

There is a warning appears in console when there is no subheader set for CardHeader component

Below forked sandbox from example: https://material-ui-next.com/demos/cards/
https://codesandbox.io/s/04yxqkrwml — check dev tools console

screen shot 2017-12-19 at 3 12 33 pm

Card good first issue

Most helpful comment

I can give it a crack with a PR, if no one's on it yet.

All 10 comments

@alex-hudenko What's your use case for having an empty CardHeader?

@oliviertassinari CardHeader is not empty but on my card I need title only.

This code will trigger warning:
```
title={organization.name}
avatar={



}
/>

To suppress warning I have to set empty subtitle:

title={organization.name}
subtitle="" // <------ It's not obvious and anti-pattern I think
avatar={



}
/>

@alex-hudenko Maybe it's surfacing an issue where the block shouldn't be rendered:
https://github.com/mui-org/material-ui/blob/5f50ef1db6c937f462c3544e4040826de3876596/src/Card/CardHeader.js#L42-L49

@oliviertassinari According to propTypes subheader property is not required

```jsx
CardHeader.propTypes = {
subheader: PropTypes.node,
}

// Threre should be something like:

{
subheader
?
type={avatar ? 'body2' : 'body1'}
component="span"
color="secondary"
className={classes.subheader}
>
{subheader}

:
null
}

@alex-hudenko Yes, I think that we should update the CardHeader.js implementation with a ternary condition on subheader 👍 .

This started happening to me just now, after upgrading from v1.0.0-beta.23 to v1.0.0-beta.24. On the former version it did not happen. Now the warning is all over the place when I run my tests.

I can give it a crack with a PR, if no one's on it yet.

@gnapse Yes, please 💃 :).

@gnapse Sorry, I had a go at fixing this before I saw this issue. It's been failing builds in our application since we updated yesterday (?). Happy to remove my PR if you have already started working on it mate. Have added your issue # to the commit / PR #9572.

@jwwisgerhof if you already made progress on this is all yours. I would've started around now, so I haven't yet done anything about it.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

garygrubb picture garygrubb  ·  57Comments

iceafish picture iceafish  ·  62Comments

tdkn picture tdkn  ·  57Comments

kybarg picture kybarg  ·  164Comments

gndplayground picture gndplayground  ·  54Comments