I'm using: method = () => { }
so i don't need to bind the function
here's my class:
class Form extends Component {
constructor(props) {
super(props);
this.state = {
disabledFields: [],
};
}
executeCode = ( methodCode ='', params = {} ) => {
const result = crudCode[methodCode](params);
if (result && result.newStates) {
Object.keys(result.newStates).map(function(keyName, keyIndex) {
this.setState( { nada: 'nada' });
});
}
}
I get this error:
TypeError: Cannot read property 'setState' of undefined
> 48 | this.setState( { nada: 'nada' });
what I'm doing wrong, I've already used this type of function and setState, but i don't know this time it does not work.