Skip to content

Commit

Permalink
Merge pull request #4990 from oliviertassinari/icon-menu-warn-no-icon…
Browse files Browse the repository at this point in the history
…-button-child

[IconMenu] Warn when not providing an IconButton to iconButtonElement
  • Loading branch information
oliviertassinari authored Aug 15, 2016
2 parents 13bc741 + 0ad7f2a commit 08e8765
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/IconMenu/IconMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import Events from '../utils/events';
import propTypes from '../utils/propTypes';
import Menu from '../Menu/Menu';
import Popover from '../Popover/Popover';
import warning from 'warning';

class IconMenu extends Component {
static muiName = 'IconMenu';
Expand Down Expand Up @@ -264,6 +265,9 @@ class IconMenu extends Component {
const mergedRootStyles = Object.assign(styles.root, style);
const mergedMenuStyles = Object.assign(styles.menu, menuStyle);

warning(iconButtonElement.type.muiName === 'IconButton',
'We are expecting an <IconButton /> to be passed to the `iconButtonElement` property.');

const iconButton = React.cloneElement(iconButtonElement, {
onKeyboardFocus: onKeyboardFocus,
iconStyle: Object.assign({}, iconStyle, iconButtonElement.props.iconStyle),
Expand Down

0 comments on commit 08e8765

Please sign in to comment.