react-native-gifted-chat icon indicating copy to clipboard operation
react-native-gifted-chat copied to clipboard

Send is clearing state regardless of passing the Text and OnInputTextChanged props

Open alexanderblackh opened this issue 2 years ago • 1 comments

Issue Description

Following the documentation, I've set up a local state for managing the text (I've also tried the same via Redux and Context). However, on send it's still clearing

Steps to Reproduce / Code Snippets

import { GiftedChat } from 'react-native-gifted-chat';

const App = () => {
  const [messages, setMessages] = useState([]);
  const [messageDraft, setMessageDraft] = useState('');

  const handleSendMessage = useCallback((newMessages = []) => {
    setMessages(previousMessages => GiftedChat.append(previousMessages, newMessages));
  }, []);

  return (
    <GiftedChat
      messages={messages}
      onSend={handleSendMessage}
      user={{ _id: 1, name: 'User' }}
      text={messageDraft}
      onInputTextChanged={setMessageDraft}
    />
  );
};

export default App;

Expected Results

Pressing send shouldn't clear unless I specifically reset the value in state.

Additional Information

  • Nodejs version: v19.1.0
  • React version: 18.2.0
  • React Native version: 0.71.6
  • react-native-gifted-chat version: ^2.1.0
  • Platform(s) (iOS, Android, or both?): Both
  • TypeScript version: 4.8.3

alexanderblackh avatar May 11 '23 02:05 alexanderblackh

if you using state to manage the text, so you can typing much text into composer then see how it lag

fukemy avatar May 16 '23 07:05 fukemy