2 ms·
You could just imperatively instrument the component, e.g.: class MyComponent extends React.Component { /* ... */ } debugReasonForRendering(MyComponent
by jkrems 10y ago
You could just imperatively instrument the component, e.g.:
class MyComponent extends React.Component { /* ... */ }
debugReasonForRendering(MyComponent);
Where `debugReasonForRendering` patches `arguments[0].prototype. shouldComponentUpdate`.
- adriancooney 10y agoSince this is entirely for debugging purposes, I feel like the decorator is perfectly fine until the standard is complete. It's unobtrusive (i.e. no refactoring needed) and easy to remember. Maybe a warning inside the decorator is `process.env.NODE_ENV === "production"` warning would be nice.