The onSend(messages) function doesn't seem to have a callback.
So, for example, if the app cannot connect to the backend the input field text will be cleared no matter if the message was sent successfully or not.
For example, the device is offline, I would like to show an error and allow to retry once it's connected again.
The onSend() to have a callback to handle this.
+1
Is it possible that textInput keep text when onSend return false?
The text is always cleared in Send.js https://github.com/FaridSafi/react-native-gifted-chat/blob/master/src/Send.js#L14 calling the following function with true https://github.com/FaridSafi/react-native-gifted-chat/blob/master/src/GiftedChat.js#L325.
The solution I used is to override the renderSend combined with controlling the text property with onInputTextChanged.
renderSend = props => (
<Send
{...props}
onSend={this.handleOnSend}
}}
/>
);
<GiftedChat
....
text={/* text from state manager */}
onInputTextChanged={/* store your text somewhere */}
renderSend={this.renderSend}
....
/>
Now it's up to you to clear the input field after each send.
@ewal awesome thanks!
@gianpaj, hope it helps! Just ping me if you want a complete code example. Otherwise, maybe we could close this issue?
@ewal can you share complete code example
Most helpful comment
+1
Is it possible that textInput keep text when onSend return false?