Skip to content

Commit

Permalink
[IconMenu] Removed props.ref call
Browse files Browse the repository at this point in the history
Calls to props.ref will throw a warning in React v15.  This commit hard-codes the
value instead of reading props.ref.  The iconButtonRef element has been removed
from the state object, since it never changes after the component is initialized.

React warnings discussed in this PR:
facebook/react#5744
  • Loading branch information
jakeboone02 authored and Cuong Le committed Apr 20, 2016
1 parent 89cbc9c commit 62d4d0e
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/IconMenu/IconMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,6 @@ class IconMenu extends React.Component {
};

state = {
iconButtonRef: this.props.iconButtonElement.props.ref || 'iconButton',
menuInitiallyKeyboardFocused: false,
open: false,
};
Expand Down Expand Up @@ -205,7 +204,7 @@ class IconMenu extends React.Component {
this.setState({open: false}, () => {
// Set focus on the icon button when the menu close
if (isKeyboard) {
const iconButton = this.refs[this.state.iconButtonRef];
const iconButton = this.refs.iconButton;
ReactDOM.findDOMNode(iconButton).focus();
iconButton.setKeyboardFocus();
}
Expand Down Expand Up @@ -293,7 +292,7 @@ class IconMenu extends React.Component {
this.open(Events.isKeyboard(event) ? 'keyboard' : 'iconTap', event);
if (iconButtonElement.props.onTouchTap) iconButtonElement.props.onTouchTap(event);
},
ref: this.state.iconButtonRef,
ref: 'iconButton',
});

const menu = (
Expand Down

0 comments on commit 62d4d0e

Please sign in to comment.