move _.uniqueId() out of render function

This commit is contained in:
KDSBrowne 2017-12-15 20:25:41 -08:00
parent 284ab5e628
commit f1cd5f2d6e
2 changed files with 14 additions and 5 deletions

View File

@ -41,6 +41,10 @@ class ActionsDropdown extends Component {
this.handlePresentationClick = this.handlePresentationClick.bind(this);
}
componentDidMount() {
this.uniqueId = _.uniqueId('actions-list-item-');
}
componentWillUpdate(nextProps) {
const { isUserPresenter: isPresenter } = nextProps;
const { isUserPresenter: wasPresenter, mountModal } = this.props;
@ -76,12 +80,12 @@ class ActionsDropdown extends Component {
{
[
(<DropdownListItem
key={_.uniqueId('actions-list-item-')}
key={this.uniqueId}
icon="presentation"
label={intl.formatMessage(intlMessages.presentationLabel)}
description={intl.formatMessage(intlMessages.presentationDesc)}
onClick={this.handlePresentationClick}
/>)
/>),
]
}
</DropdownList>

View File

@ -84,6 +84,11 @@ class UserListContent extends Component {
this.getDropdownMenuParent = this.getDropdownMenuParent.bind(this);
}
componentWillMount() {
this.title = _.uniqueId('dropdown-title-');
this.seperator = _.uniqueId('action-separator-');
}
componentDidUpdate() {
this.checkDropdownDirection();
}
@ -286,11 +291,11 @@ class UserListContent extends Component {
(
<DropdownListTitle
description={intl.formatMessage(messages.menuTitleContext)}
key={_.uniqueId('dropdown-list-title')}
key={this.title}
>
{user.name}
</DropdownListTitle>),
(<DropdownListSeparator key={_.uniqueId('action-separator')} />),
</DropdownListTitle>),
(<DropdownListSeparator key={this.seperator} />),
].concat(actions)
}
</DropdownList>