I'm using a library for working with the content of files. I'm using the function
instead of arrow function
because I need to access the decode method
. But then I want to set the result of a function to a state of the component. But of course, in that case, this is not pointing to the component anymore.
I'm not sure what to do there?
reader.loadFile(file)
.then((response) => {
reader.iterateLines({
eachLine: function (raw, progress, lineNumber) {
console.log(this.decode(raw))
this.setState({
txtFileContent: this.decode(raw)
});
},
})
})
.catch( (reason): void => {
console.log(this);
});