why i cant access to variable "rows" in method parse? If i put this.setState({rows: [3,2]}); outside of "parseString it works, but what to do to make it work inside this method?
class App extends React.Component {
constructor(props) {
super(props);
this.state = this.getCleanState();
this.parse = this.parse.bind(this);
}
getCleanState() {
return {
isLoading: true,
columns:[
{ name: 'a:ClientID', title: 'ID kombinace'},
{ name: 'a:Name', title: 'Název kombinace'},
],
defaultColumnWidths: [
{ columnName: 'a:ClientID', width: 160 },
{ columnName: 'a:Name', width: 200 },
],
rows:[],
selection: [],
};
}
parse(XML){
var parseString = require('react-native-xml2js').parseString;
var xml = XML;
parseString(xml, function (err, result) {
console.dir(result);
this.setState({rows: [3,2]});
});
}