我在有状态的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