question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Update when receiving new messages

See original GitHub issue

I’m running the chat using two simulators (Android and IOS) where each have different users chatting between. Using loadEarlier, isLoadingEarlier and onLoadEarlier I’m trying to update the chat as I receive new messages.

I thought that when using onLoadEarlier I would be able to get notice about the new messages, but it’s clearly that I’m missing something.

I also thought about use some Interval to check for new data, but I don’t see this as a good option.

constructor (props) {
    super(props)

    this.state = {
        loadEarlier: true,
        isLoadingEarlier: false,
        messages: []
    }

    this.onLoadEarlier = this.onLoadEarlier.bind(this)
}
_load () {
    api.getMessages().then((response) => {
        this.setState((previousState) => {
            return { messages: response, isLoadingEarlier: false }
        })
    })
}
onLoadEarlier () {
    this.setState((previousState) => {
      return { isLoadingEarlier: true }
    })
    this._load()
}
<GiftedChat
messages={this.state.messages}
loadEarlier={this.state.loadEarlier}
onLoadEarlier={this.onLoadEarlier}
isLoadingEarlier={this.state.isLoadingEarlier}

Additional Information

  • React Native version: 0.47.2
  • react-native-gifted-chat version: 0.2.7
  • Platform(s) (iOS, Android, or both?): both

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:6

github_iconTop GitHub Comments

2reactions
AMoktarcommented, Feb 7, 2021

So, How can I update UI when new message received ?

0reactions
EliotRavencommented, Jul 27, 2022

So, How can I update UI when new message received ?

the same questions

Read more comments on GitHub >

github_iconTop Results From Across the Web

If you can't send or receive messages on your iPhone or iPad
In the Settings app, tap Messages. Turn iMessage off and then back on. Tap Send & Receive. Tap the phone number that you...
Read more >
How to Fix Not Receiving Text Messages on Android
How to Fix Not Receiving Text Messages on Android · Turn Off iMessage on Your iPhone · Toggle the Airplane Mode on Your...
Read more >
Messages Still Delivered to Old Phone After Activating New ...
Messages may not be immediately delivered to the new phone after disabling the chat service on the old one. Google must sever the...
Read more >
Google Messages Just Received a New Update With Heap of ...
You can read more about Google Messages and all the changes that you have received here.
Read more >
Messages app not receiving text messages after Android 11 ...
Update 2:- As of today May 25 2021, the default SMS app is working as well. It started working suddenly, a day ago....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found