Lag when there are a lot of messages
See original GitHub issueIssue Description
Noticeable lag when there are a lot of messages and multiple sender. is this to be expected or am i doing something wrong?
Steps to Reproduce / Code Snippets
send a lot of message from multiple sender
Expected Results
Minimum lag
Additional Information
- Nodejs version: 6.11.0
- React version: 16.0.0-alpha.6
- React Native version: 0.44.2
- react-native-gifted-chat version: 0.4.3
- Platform(s) (iOS, Android, or both?): Android
code
import React, { Component } from 'react';
import {
AppRegistry,
StyleSheet,
Text,
View
} from 'react-native';
import SocketIOClient from 'socket.io-client';
import { GiftedChat } from 'react-native-gifted-chat'
export default class rn_ws_app extends Component {
constructor(props){
super(props);
this.state = {
messages:[]
}
this.onReceiveMessage = this.onReceiveMessage.bind(this);
this.socket = SocketIOClient('http://192.168.1.137:3000');
this.socket.on('message', this.onReceiveMessage);
}
onReceiveMessage(message) {
this.setState(previousState => ({
messages: GiftedChat.append(previousState.messages, [message]),
}))
}
onSend(messages = []) {
this.socket.emit('message', messages[0]);
this.setState(previousState => ({
messages: GiftedChat.append(previousState.messages, messages)
}))
}
render() {
return (
<GiftedChat
messages={this.state.messages}
onSend={messages => this.onSend(messages)}
user={{
_id: 1,
}}
/>
)
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#F5FCFF',
},
welcome: {
fontSize: 20,
textAlign: 'center',
margin: 10,
},
instructions: {
textAlign: 'center',
color: '#333333',
marginBottom: 5,
},
});
AppRegistry.registerComponent('rn_ws_app', () => rn_ws_app);
Issue Analytics
- State:
- Created 5 years ago
- Comments:14
Top Results From Across the Web
My words lag and slow down when I'm typing fast during a text ...
That depends on why they are lagging. If they are lagging because your computer is busy, then you need to reduce the load...
Read more >Message app slow and lags on Big Sur - Apple Community
The Messages app (which you send and receive iMessages with) becomes very slow and unresponsive after upgrading to Big Sur.
Read more >Why Is My Phone Lagging? 6 Possible Causes - MakeUseOf
Signs of lag include delays in touch responsiveness, app freezes, and slow performance. If your phone lags, it may have difficulties ...
Read more >(Android) TextInput lag when there are a lot of messages
When user enter large text (50+ characters) and remove it then repeat process again 2 or more times. <TextInput onChangeText={(text) => this.
Read more >Text thread lag with just one person, how can I fix the lag?
As B. Diddy has said above, if there are a lot of messages in that particular thread with that specific contact, a lag...
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 had the same issue and I was able to fix by commenting the line
value={this.props.text}
in Composer.jsFound 2 ways to speed things up:
return inverted ? messages.concat(currentMessages) : currentMessages.concat(messages);
to
return inverted ? [...messages,...currentMessages] : currentMessages.concat(messages);