rn-eventsource
rn-eventsource copied to clipboard
Not working in RN 0.62
Hello, With React Native 0.61 I was using this pollyfill: https://github.com/jordanbyron/react-native-event-source
Everything worked perfectly, but then React native released new version - 0.62. I created new project for testing purposes and suddenly it stopped working.
So I installed this library and it does not work either. Request with authorization token succeeds so I have no idea why no message is coming. I am testing on physical Android device.
import EventSource from 'rn-eventsource'
class SSE {
constructor() {
this.eventSource = null
this.init()
}
init() {
const options = { headers: { Authorization: 'Bearer ' + data.token } }
this.eventSource = new EventSource(env.urls.apiUrl + '/event', options)
console.log(this.eventSource)
this.eventSource.onmessage = (event) => {
console.log(event);
}
}
close() {
if (this.eventSource) {
this.eventSource.close()
this.eventSource = null
}
}
}
export default new SSE()
Same here, tested with this http://express-eventsource.herokuapp.com/ demo;