bugsnag-js: TypeError: Cannot read property 'createErrorBoundary' of undefined
Following the Bugsnag Docs to config the project and run got this error from:
const ErrorBoundary = Bugsnag.getPlugin('react').createErrorBoundary(React);
- react 16.11.0
- react-native 0.62.2
- @bugsnag/react-native 7.5.0
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 7
- Comments: 24 (10 by maintainers)
Can you please reference this in your documentation until this is released? I just spend 2-3 hours thinking I setup my app was wrong, meticulously looking at the docs, but it looks like this feature just doesn’t work at all with recent versions of react-native and bugsnag, even with the base case in the documentation.
Hey @adkenyon, we’re looking into a fix for this notifier side. But, in the meantime you can guard against this by checking whether the
getPlugin()call returnsundefined, and in these cases point your application to a no-opErrorBoundary, for example:When running without the debugger, Bugsnag will continue as normal with the Bugsnag error boundary.
That does look like a bug, although one that would only have an impact when the debugger is attached.
We’ll look into whether this can be resolved in a future release.
@xander-jones thank you for the workaround!
@duzliang The issue is that you’re calling
Bugsnag.getPlugin('react')before you callBugsnag.start().Bugsnag.start()must be called before any other method so you’ll need to move it out of the constructor of your component.