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

Appending previous messages crashes the app

Open biswanathTewari opened this issue 1 year ago • 0 comments

Issue Description

The app crashes when we try to append previous messages to the global state. This happens only while loading earlier messages and passing the global state of messages to Gifted Chat. This issue goes away when we prepend instead of appending or don't pass the global state to GiftedChat.

Steps to Reproduce / Code Snippets

  1. Pass the state containing an array of messages to Gifted Chat
  2. Try to append the previous messages to the global state while loading earlier messages
  3. code snippet to mutate the state:- loadEarlierMsgsSuccess: (state, action: PayloadAction<Array<IMessage>>) => { state.isLoadingEarlier = false; state.msgs = [...state.msgs, ...action.payload]; },
  4. Screenshot 2022-10-20 at 7 38 03 PM

Additional Information

  1. Looked into if any of our hooks could be the problem, but that is not the case, we only have one useEffect(), with an event listener.
  2. The state mutation works if we don't pass the state to GiftedChat or send a limited, static number of messages
  3. pretending seems to work but appending not
  4. tried replacing global state with local state as well
  • Nodejs version: v14.17.6
  • React version: 18.1.0
  • React Native version: 0.70.2
  • react-native-gifted-chat version: ^1.0.4
  • Platform(s) (iOS, Android, or both?): both
  • TypeScript version: [FILL THIS OUT]

biswanathTewari avatar Oct 20 '22 14:10 biswanathTewari