反应本地

时间:2018-11-20 03:17:27

标签: javascript react-native

我正在学习React Native,我遇到了一个将SendBird SDK实施到react native聊天应用程序项目中的示例代码。在项目中有这行代码

_onInvite() {
var _SELF = this;
if (!_SELF.state.channel) {
  sb.GroupChannel.createChannel(this.state.inviteList, false, function(channel, error) {
    if (error) {
      console.log(error);
      return;
    }
    _SELF.props.navigator.replace({name: 'chat', channel: channel, _onHideChannel:_SELF.props.route._onHideChannel, refresh: _SELF.props.route.refresh});
  });
} else {
  var _inviteIds = this.state.inviteList.map(function(user) {return user.userId});
  _SELF.state.channel.inviteWithUserIds(_inviteIds, function(response, error) {
    if (error) {
      console.log(error);
      return;
    }
    _SELF.props.navigator.pop();
  });
}
}

我可以知道代码中this语法用法的区别是什么?为什么需要将变量声明为this,而不在_SELF中使用this.state.inviteList?前几行代码使用_SELF。有人愿意详细解释有关我的这种困惑吗?

0 个答案:

没有答案