JE42 JE42 - 3 months ago 25
React JSX Question

Debugging React propType warnings

I have propType expressions that sometimes are emitting warnings.

When that happens, I would like to inspect the object causing the warning since the warning message in the console is in same cases not helpful enough.

I tried to debugging through the spec code of react to find the right spot for the breakpoint, however i would expect there is an easier way to get more diagnostic information about the warning.

Answer

Want the ugly solution? Because that's all I have.

Stick this in your main application file.

const error = console.error;
console.error = (...args) => {
    debugger;
    error.apply(null, args);
}

And use the debugger to walk up the callchain till you find checkReactTypeSpec and look at its arguments.