Move unique ids to constructor

This commit is contained in:
Tainan Felipe 2020-05-05 13:33:28 -03:00
parent fef2d8aa2f
commit 6e43f262da
3 changed files with 4 additions and 17 deletions

View File

@ -143,6 +143,8 @@ class UserDropdown extends PureComponent {
showNestedOptions: false, showNestedOptions: false,
}; };
this.title = _.uniqueId('dropdown-title-');
this.seperator = _.uniqueId('action-separator-');
this.audio = new Audio(`${Meteor.settings.public.app.cdn + Meteor.settings.public.app.basename}/resources/sounds/bbb-handRaise.mp3`); this.audio = new Audio(`${Meteor.settings.public.app.cdn + Meteor.settings.public.app.basename}/resources/sounds/bbb-handRaise.mp3`);
this.handleScroll = this.handleScroll.bind(this); this.handleScroll = this.handleScroll.bind(this);
@ -154,11 +156,6 @@ class UserDropdown extends PureComponent {
this.makeDropdownItem = this.makeDropdownItem.bind(this); this.makeDropdownItem = this.makeDropdownItem.bind(this);
} }
componentWillMount() {
this.title = _.uniqueId('dropdown-title-');
this.seperator = _.uniqueId('action-separator-');
}
componentDidUpdate() { componentDidUpdate() {
this.checkDropdownDirection(); this.checkDropdownDirection();
} }

View File

@ -11,18 +11,13 @@ export default class ToolbarMenuItem extends Component {
// a flag to keep track of whether the menu item was actually clicked // a flag to keep track of whether the menu item was actually clicked
this.clicked = false; this.clicked = false;
this.uniqueRef = _.uniqueId('toolbar-menu-item');
this.handleTouchStart = this.handleTouchStart.bind(this); this.handleTouchStart = this.handleTouchStart.bind(this);
this.handleOnMouseUp = this.handleOnMouseUp.bind(this); this.handleOnMouseUp = this.handleOnMouseUp.bind(this);
this.handleOnMouseDown = this.handleOnMouseDown.bind(this); this.handleOnMouseDown = this.handleOnMouseDown.bind(this);
this.setRef = this.setRef.bind(this); this.setRef = this.setRef.bind(this);
} }
// generating a unique ref string for the toolbar-item
componentWillMount() {
this.uniqueRef = _.uniqueId('toolbar-menu-item');
}
componentDidMount() { componentDidMount() {
// adding and removing touchstart events can be done via standard React way // adding and removing touchstart events can be done via standard React way
// by passing onTouchStart={this.funcName} once they stop triggering mousedown events // by passing onTouchStart={this.funcName} once they stop triggering mousedown events

View File

@ -7,17 +7,12 @@ import { styles } from '../styles';
export default class ToolbarSubmenuItem extends Component { export default class ToolbarSubmenuItem extends Component {
constructor() { constructor() {
super(); super();
this.uniqueRef = _.uniqueId('toolbar-submenu-item');
this.handleTouchStart = this.handleTouchStart.bind(this); this.handleTouchStart = this.handleTouchStart.bind(this);
this.handleOnMouseUp = this.handleOnMouseUp.bind(this); this.handleOnMouseUp = this.handleOnMouseUp.bind(this);
this.setRef = this.setRef.bind(this); this.setRef = this.setRef.bind(this);
} }
// generating a unique ref string for the toolbar-item
componentWillMount() {
this.uniqueRef = _.uniqueId('toolbar-submenu-item');
}
componentDidMount() { componentDidMount() {
// adding and removing touchstart events can be done via standard React way // adding and removing touchstart events can be done via standard React way
// by passing onTouchStart={this.funcName} once they stop triggering mousedown events // by passing onTouchStart={this.funcName} once they stop triggering mousedown events