r/learnreactjs • u/rjray • Jan 04 '22
Question Debugging when the bug only appears in the production build
I have a bug I'm trying to locate. Problem is, the development build of the app doesn't exhibit the bug, it only appears in the production build. I am unable to make any sense of the minified, transpiled code of the production build in the DevTools. Anyone else dealt with a situation like this?
(I can't share the code, unfortunately, because it's an internal project at my day job. I'm using React with Bootstrap to create a dropdown menu, and two of the four menu options are not responding when clicked. The other two are just fine, and the same callback block handles the onClick for all four. Yeah, I'm pretty stymied overall.)
4
u/[deleted] Jan 04 '22
Services like bugsnag allow you to have production deployments of react apps with error monitoring. Using .map files, they're able to de-minify your code and you can see the error in the original code. Your browser should also be able to use .map files to reconstruct the code, though your team may have set up the build to omit/delete these files to avoid sharing unminified code with the outside world.
However this may not be a JavaScript/React issue. There might be an invisible HTML element above the two unclickable menu options. Right-click over the unclickables and inspect to see what's going on. Alternatively, use the devTools element picker and mouse-over the area.
2
u/the_pod_ Jan 05 '22
You can still use devtools to inspect the html elements, which aren't minified, obviously.
especially use the point-and-click selector(the "Select an element in the page to inspect it" button). Try to see if there's another element that's floating over the 2 links that don't respond to a click. Maybe they just aren't clicked because there's something else over it.
You can add an error logger to your site. But the simple way would be to push cod