【问题标题】:How can I use react-native-actionsheet alongside react-native-gifted-chat in the same view?如何在同一视图中将 react-native-actionsheet 与 react-native-gifted-chat 一起使用?
【发布时间】:2018-02-15 13:35:07
【问题描述】:

使用这个天才聊天库https://github.com/FaridSafi/react-native-gifted-chat

我尝试将 ActionSheet 添加到渲染函数,但它不会渲染天才聊天,因为聊天屏幕仅在它是唯一的根视图控件时才有效。

此渲染函数不适用于外部封闭View

return (
  <View>
    <GiftedChat
      messages={this.state.messages}
      onSend={this.onSend}
      onPressAvatar={this.pressProfile}
      user={{
        _id: user.id,
        name: user.username,
        avatar: user.thumbnail,
      }}
    />
    <ActionSheet
      ref={o => this.ActionSheet = o}
      title={title}
      options={options}
      cancelButtonIndex={CANCEL_INDEX}
      destructiveButtonIndex={DESTRUCTIVE_INDEX}
      onPress={this.handlePress}
    />
  </View>
);

如果我必须将根视图设为GiftedChat,我应该将 ActionSheet 视图放在哪里?

【问题讨论】:

    标签: react-native react-native-android


    【解决方案1】:

    你试过了吗?

    <GiftedChat
      messages={this.state.messages}
      onSend={this.onSend}
      onPressAvatar={this.pressProfile}
      user={{
        _id: user.id,
        name: user.username,
        avatar: user.thumbnail,
      }}
    >
       <ActionSheet
         ref={o => this.ActionSheet = o}
         title={title}
         options={options}
         cancelButtonIndex={CANCEL_INDEX}
         destructiveButtonIndex={DESTRUCTIVE_INDEX}
         onPress={this.handlePress}
      />
    </GiftedChat>
    

    【讨论】:

    • 我有...它说 this.ActionSheet 为空
    • 也许你需要绑定它。试试this.ActionSheet.bind(this)。或者甚至可能是this.ActionSheet.bind(ActionSheet),尽管我不确定两者都行得通。
    • 我有 - 仍然为空
    • 你能创造一种我们可以破解的零食吗?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-02-12
    • 1970-01-01
    • 1970-01-01
    • 2021-10-03
    • 2022-07-11
    • 1970-01-01
    相关资源
    最近更新 更多