Questions123
Questions123

Reputation: 374

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!

Upvotes: 1

Views: 3342

Answers (2)

Gunjan Mistry
Gunjan Mistry

Reputation: 1

Set the minInputToolbarHeight attribute to zero:

<GiftedChat
    ...
    minInputToolbarHeight=0
/>

Upvotes: 0

dansiemens
dansiemens

Reputation: 578

Just pass null for the prop renderInputToolbar:

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

Upvotes: 3

Related Questions