如何在同一视图中使用react-native-actionsheet和react-native-gifted-chat?

时间:2017-09-06 23:35:45

标签: react-native react-native-android

使用这个有天赋的聊天库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视图?

1 个答案:

答案 0 :(得分:0)

你试过这个吗?

<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>