0
반응, Object.keys 내부 정의의 특성 'setState를'을 읽을 수 없습니다 :내가 사용하고
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 : method =() => { }
그래서 내가 기능 여기
을 결합 할 필요가 없습니다 나의 클래스의 이 오류를 얻을 :
내가 잘못 뭘하는지TypeError: Cannot read property 'setState' of undefined
> 48 | this.setState({ nada: 'nada' });
, 나는 이미 기능과 setState를이 유형을 사용했습니다,하지만 난 그것이 작동하지 않는이 시간을 알 수 없습니다.
가능한 복제 [? 콜백 내에서 올바른 \ '이 \를'에 액세스하는 방법 (https://stackoverflow.com/questions/20279484/how-to -access-the-correct-this-call-inside-a-callback) – Li357