我在有狀態的React組件中有一個函數,我得到的是Proxy
,而不是我實際期望的函數參數。React函數參數是一個代理?
這是怎麼回事?我期望在我的日誌中看到hello world
,但是我卻看到:
這是什麼?代理{dispatchConfig:對象,_targetInst:構造函數,nativeEvent: 對象,類型:未定義,目標:196 ...} [[處理程序]:對象[[目標] :ResponderSyntheticEvent [[IsRevoked]]:假
class MyComponent extends Component {
state={}
toggleModal = (A) => {
console.log('what is this?', A)
this.setState((prevState, props) => {
return { openShippingModal: !prevState.openShippingModal };
});
}
anotherFunctionInMyComponent = selection => {
///do stuff
this.toggleModal('hello world');
};
componentDidMount =() => {
/* do sutff */
}
render(){
//return stuff
}
我認爲你說的是某種合成事件,但是'A.target.value'返回undefined,'A.type'返回272.我添加了更多的代碼來幫助你查看組件的結構。 – Turnipdabeets