I am trying to learn React with Typescript and seeking advice. I have successfully managed to get a Webpack build working for development and production (minified js with source-map) environments.
I have an error boundary component implementing the componentDidCatch method with signature:
componentDidCatch(error: Error, info: ErrorInfo)
I have managed to render a readable stack trace from the minified bundle and source map using sourcemapped-stacktrace. This works fine for the Error object.
According to the React documentation a component stack trace should be logged/rendered in a development environment only.
Does the component stack trace correspond to the componentStack property of the ErrorInfo object that is an argument in the componentDidCatch method?
If so, is it considered best practice for an error boundary to only log/display ErrorInfo.componentStack when an environment variable is set with a value indicating that a development environment is running?
Currently, I am displaying/logging ErrorInfo.componentStack for both development and production builds. In production it only displays minified stack trace, despite using
a package, such as sourcemapped-stacktrace.