New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issue/490 #492
Conversation
opponentInGame = () => { | ||
const { opponentPlayer, chatUsers } = this.props; | ||
const findedUser = _.find(chatUsers, user => (opponentPlayer.id === user.id)); | ||
return typeof findedUser !== 'undefined'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Лучше писать _.isEmpty
или isUndefined
@@ -76,6 +87,12 @@ class RematchButton extends React.Component { | |||
</button> | |||
); | |||
|
|||
opponentInGame = () => { | |||
const { opponentPlayer, chatUsers } = this.props; | |||
const findedUser = _.find(chatUsers, user => (opponentPlayer.id === user.id)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Есть еще сокращенная форма у лодаша _.find(chatUsers, {id: opponentPlayer.id});
</button> | ||
); | ||
renderBtnAfterSendOffer = () => { | ||
const text = this.opponentInGame() ? 'Wait Answer...' : 'Opponent Left Game'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
waiting for an answer
opponent left the game
const classNames = cn({ | ||
btn: true, | ||
'btn-secondary': this.opponentInGame(), | ||
'btn-warning': !this.opponentInGame(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Лучше вычислить один раз и в переменную положить в начале функции
No description provided.