0

I used error boundary inside (componentDidCatch)I want to log which react component is break in producation build.

conclusion is get react component Name inside componentDidCatch in producation build.

I read many article and below link this is same as I asked in question but it's not solve my problem. Getting React Component by name

and I also saw some webpack related things (production config's uglify) but it's not proper clear.

let me know if any simplest way to solve this issue

Gaurav Sharma
  • 51
  • 1
  • 11

1 Answers1

0

By design, you should never be able to see debugging information in a production build. What you are trying to accomplish here is an anti-pattern. However, if you still want to go through with it, you can use:

this._reactInternalFiber.elementType.name 

Note that it might be instable due to using a private property that belongs to React.

  • How its solve the problem ? I am logging error & sent log to the server In componenttDidCatch if I am writing this._reactInternalFiber.elementType.name It's give only current Component name. not a breaking component name. If this code works then let me know correct place where i put and take error component name. – Gaurav Sharma Nov 05 '19 at 15:57
  • @GauravSharma Your question was `How to get react component Name in producation build?` and I have answered that. You cannot get a specifically _breaking_ component in a production build. Because you are in a _production_ build. This is not designed to give you debugging info. A _debug_ build will let you do that. –  Nov 05 '19 at 16:10
  • Thanks for answer @reg, But I need to creak this problem. – Gaurav Sharma Nov 05 '19 at 16:16