Search code examples
react-nativereact-native-gifted-chat

React Native Gifted Chat: How to hide keyboard and text input


I am making a react native application using expo and am using react-native-gifted-chat for a chat like feature (https://github.com/FaridSafi/react-native-gifted-chat). In this feature, I only want certain users to be able to send a message. The users who cant should only be able to view the messages that have been sent.

In order to implement this, I need a way to hide the keyboard/text input for the users who are not authorized to send a message. I was reading through the documentation and am unsure of how to do this. Is there a way to hide the keyboard/text input and only load the messages?

Not sure if this is relevant but my code for the gifted chat is as follows:

<GiftedChat
      messages={this.state.messages}
      placeholder="Send your thoughts?"
      onSend={(messages) => this.sendMessage(messages)}
      user={{
        ...user details
      }}
/>

Thanks!


Solution

  • Just pass null for the prop renderInputToolbar:

    <GiftedChat
        ...
        renderInputToolbar={() => { return null }}
    />