jsnlog.js
jsnlog.js copied to clipboard
JSNLog Not resetting xhr object in React native
I have written code as below in react native. But I am seeing only one message(very first message) in the server.
Any consecutive requesting fails with [Error: Cannot open, already sending]
import {JL} from 'jsnlog'
var app = JL.createAjaxAppender("appender").setOptions({
'url': 'http://127.0.0.1:8080/log'
});
JL().setOptions({
"appenders": [app]
});
class App extends React.Component {
componentDidMount () {
JL().info('Application started')
JL()..debug('Application started with no config')
}
render() {
return(
<div className ="container-fluid">
<Header />
<Switch>
<Route exact path ="/" component ={HomePage} />
<Route path ="/about" component ={AboutPage} />
<Route path ="/courses" component ={CoursesPage} />
<Route component={PageNotFound} />
</Switch>
</div>
)
}
}
export default App;
Temporarily, we tried re-initialized XHR object inside the
AjaxAppender.prototype.sendLogItemsAjax = function (logItems, successCallback) {
this.xhr = JL._createXMLHttpRequest()
// rest of the code
}```
I encountered the same issue on a react-native app. will there be a fix for this?
I am not familiar with React Native, so not really in a position to investigate this. But if you could send me a pull request with a fix, that would be great.
I've created a feature branch with the fix but I'm not authorized to push it. @mperdeck can you give me access for this?
Did you try to push to my repo directly, or create a pull request?
Creating a pull request would be the way to go. To do that, you'd first create a fork, make your updates on the fork, then create the pull request to get the changes into my repo.
See https://guides.github.com/activities/forking/
I created the PR: https://github.com/mperdeck/jsnlog.js/pull/77. @mperdeck , please take a look when you have the time