Rapsssito / react-native-tcp-socket

React Native TCP socket API for Android, iOS & macOS with SSL/TLS support.
MIT License
303 stars 81 forks source link

How do i remove an event listener? #163

Closed tristola closed 1 year ago

tristola commented 1 year ago

This is a question, If i have an event listener and would like to change it.

client.on('data', function(data) {
  console.log('message was received', data);
});

How can i remove or replace it ? if i add a new one it will call all the old ones too.

ricardordzalt commented 1 year ago

Have you tried saving the function in a useRef?

Rapsssito commented 1 year ago

@tristola, for this kind of questions. I would kindly ask you to submit them to forums such as Stack Overflow.