onInputTextChanged is triggered without typing after the componentDidMount()
See original GitHub issueIssue Description
The onInputTextChanged is triggered automatic when the chat view is loaded after componentDidMount( ). I need the onInputTextChanged to display that a user is currently writing to the chat. But always when a users enters a chat the method is fired automatic and it displays that someone is currently writing.
Steps to Reproduce / Code Snippets
this.onTyping = this.onTyping.bind(this);
onInputTextChanged={this.onTyping}
Expected Results
onInputTextChanged only fires when a user is currently writing.
Additional Information
- React Native version: 0.49.5
- react-native-gifted-chat version: react-native-gifted-chat@0.3.0
- Platform(s) (iOS, Android, or both?): both
Issue Analytics
- State:
- Created 6 years ago
- Reactions:5
- Comments:10
Top Results From Across the Web
Why is componentDidMount not being called when I re-render?
componentDidMount is only called once in the lifecycle of any component, re-render will not reinitialize the component.
Read more >React Lifecycle Methods Render And ComponentDidMount
When the component file is called it calls the render() method by default because that component needs to display the HTML markup or...
Read more >Using the Effect Hook - React
They let you use state and other React features without writing a class. The Effect Hook lets you perform side effects in function...
Read more >How the useEffect Hook Works (with Examples) - Dave Ceddia
Let's look at how to run code after a component mounts ( componentDidMount ), after it re-renders ( componentDidUpdate ), and before it ......
Read more >How to Solve the Infinite Loop of React.useEffect()
A pitfall you might experience when working with useEffect() is the infinite loop ... the countRef reference is updated without triggering a ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I resolved this by modifying @Huzaifaak method:
and in GiftedChat component:
A clean solution that has worked well for us is to declare an isTyping state that defaults to false. Following this example you can keep logic outside of the render:
Your handler could look something like this:
And you just call your handler within GiftedChat