FaridSafi / react-native-gifted-chat

💬 The most complete chat UI for React Native
https://gifted.chat
MIT License
13.52k stars 3.56k forks source link

Typing Indicator doesn't appear when using useReducer or Redux #2296

Open firasrg opened 1 year ago

firasrg commented 1 year ago

Issue Description

Hello! I've followed the official example, then I migrated it to react hooks API and its working with React.useState()! But, if I switch to React.useReducer() or redux. The indicator doesn't show up, which means its always false (even if my initial state is true).

Steps to Reproduce / Code Snippets

Steps:

  1. Clone the app on master branch.
  2. Run command yarn install.
  3. Execute the app with command npx expo start -c
  4. Wait for the metro bundler and Expo server to be ready.
  5. Scan QR code with device OR open on emulator (if exist on your machine).
  6. Open the app on Expo Go app.
  7. On the 1st screen press on a button labeled as "Navigate to chatbot".
  8. Press the button to navigate to the chat screen.

Links:

  1. This is the link to my Git repo.
  2. This is the link to main file.

And this is the code snippet:

export const initialState: IDiscussionState = {
  botIsTyping: true,
 //.. other state variables
};

export default function ChatBotScreen( {navigation: _navigation}: RootStackScreenProps<'ChatScreen'> ) {
    const { botIsTyping } = useRootSelector(discussionSelector);
    const [state, dispatch] = React.useReducer(DiscussionState.reducer, initialState);

    // ... some code

    return (
      <GiftedChat
                isTyping={state.botIsTyping}
               //.. other props
       />
    );
}

Expected Results

The indicator must appear on the top left side of the screen of ChatBot initially before showing any expressions or replies.

Additional Information

traxx10 commented 1 year ago

Did you install react-native-typing-animation ?

firasrg commented 1 year ago

Did you install react-native-typing-animation ?

Hi !

no, for what?