Chrome, Firefox debuggers not displaying the correct value for 'this' in a react app

后端 未结 3 1227
情深已故
情深已故 2021-01-06 18:57

Here\'s a bit of code, within a react component class (scaffolded using CRA 2)

  click = () => {
    console.log(this, \"hello\");
    let x = 1 + 1; //T         


        
3条回答
  •  长发绾君心
    2021-01-06 19:36

    An pragmatic alternative - if what you're wanting to do is inspect the state/props of a react component at a certain point, is to enter the break point as per normal - but instead of using the debugger to inspect the state - use the react dev tools plugin to actually examine the state.

    This might prove to be a bit fiddly, but it's an option.

提交回复
热议问题