debug react native app from chrome on windows machine - reactjs

I started exploring react-native. One thing which I want is should able to debug my app from chrome. I am having prior experience to cordova. Cordova renders app in chrome web view. I understand that with react-native it is not possible because react-native doesn't render app on web view.
There is an option react-native "debug in chrome". When I click this option, attached screenshot is getting opened. I enabled "pause on exception."
But nothing is happening. I am unable to see my app code at all.
I like to do step by step debugging. Is it possible? If so can some one tell how to do this?

You can definitely examine the source code, set breakpoints, etc in Chrome.
In the Sources menu, select debuggerWorker.js and then you should be able to see your project tree.
Any console.log in your code will print to the browser too. But I find the breakpoint inspection most helpful.

this is simple as you were doing in cordova.
try to put debugger; statement in your code while in debug mode.
It will set the breakpoint and you can then debug your application. No need to find out your files in debuggerWorker.js

Related

Cannot see my variables in console while debuging react app on production

I am new to the react world and trying to use it in my sharepoint environment. I am packaging the app for production with source maps and upload it to the sharepoint site that I will use it in. App runs without a problem in the sharepoint but in the developer toolbox I cannot debug it completely. I can see my js file, put the debug point, and it pauses on the point but I cannot see the variables in console as you can see in the screenshot below.
But if I try the same code in dev environment with npm start I can see the same variable in console without any problem.
Is this normal behavior or am I doing something wrong? Thanks a lot.

Confusion about Lighthouse report of unused JS for react devtools chrome extension

When I run Lighthouse for the project I am working on, I get
chrome-extension://fmkadmapgofadopljbjfkapdkoienihi/build/react_devtools_backend.js
as no1 causer of unused JS.
How is that making sense from a performance optimization perspective?
I can't control what extensions the user runs in his browser.
I also can't find anything about the React dev tools in the project.
Would highly appreciate if someone could shed some light on that issue.
I found the issue is because the file of the devTools is installed when the page is loading... and it is useless in production mode.
So go to the extension and right click on it.
Then go to the manage extensions.
Then find the "Allow this extension to read and change all your data on websites you visit" change it to "on click".

React extension is missing in Dev tools

I am trying to get my react extension working for local development, but "Components" and "Profiler" is missing in the Chrome developer tools. This only happens for local development, any other production code is displaying the two tabs in the developer tools as expected. I was wondering if this can be resolved somehow? I triple checked if the tabs are hidden on that occasion, and they are not. As said, this only happens for development version. When I click on the extension, I get the following message:
This page is using the development build of React. 🚧
Note that the development build is not suitable for production.
Make sure to use the production build before deployment.
Open the developer tools, and "Components" and "Profiler" tabs will appear to the right.
Based on this information I should have the tabs displayed.
When I go to a production app and click on the React extension, I can see the following displayed:
This page is using the production build of React. ✅
Open the developer tools, and "Components" and "Profiler" tabs will appear to the right.
And I also see those two tabs without a problem.
Any idea why this would happen? I searched for a solution, but did not encounter one. The only thing I found was someone mentioning you need to set the environment variable REACT_APP_ENV. I tried to set this value in the .env file where I defined REACT_APP_ENV='dev' as well as REACT_APP_ENV='development'. It did not resolve the issue, even with application and browser restart.
This happened to me as well. Looks like a bug in Chromium, but a temp solution is:
Change the chrome DevTools theme, only once it is required.
Now open devtools, you find the extension tab in DevTools.
You can again change the theme whatever you want to keep and this will fix your problem.
Check this out:
https://github.com/facebook/react/issues/19002#issuecomment-637462179
Was having the same issue, the Components and Profiler tabs weren't showing up, so I tried changing the theme as suggested by BobTheBuilder, that didn't work, so tried setting the debug levels to Default + Verbose (in addition to the others) in the console and they finally showed up.
The steps that helped me:
Remove React Developer Tools extension
Install React Developer Tools extension
Open a brand new tab containing react app
Open Dev Tools
React Developer Tools should be available
I had the same issue where Components and Profiler tabs were not showing. What worked for me was to open up the DevTools settings and to click the 'Restore defaults and reload' button (under the 'Sync' heading).
The steps that worked for me
Open chrome extensions
Disable the react dev tools extension
Enable the react dev tools extension
Enable Developer mode
Refresh target page
Where steps 1 and 2 are the little slide control at the bottom right of the extension in the extension manager.
Step 4 is the slider in the top right above all the extensions in the manager.

React native component wont update when remote debug

Before Im posting this question, I've tried to look up for answers on google but I could not find the solution to this problem.
I'm developing a react native application, I use redux and react native debugger to check my console and my state.
The issue that I am facing right now is my application wont update to latest changes when expo is debugging the application remotely using React Native Debugger.
Lets say I have a main screen with text "Hello World" and I change my code to "Hello Me", and when I refresh the expo/app, it is still Hello World. I've tried to reset cache, delete expo, recompile but nothing works. I have to disable remote debugging in expo in order to see any changes related to my code.
Does anyone have any idea how to solve this ?
The issue is with React Native Debugger. There is a bug that is likely related to React Native 0.61 and the "fast refresh" feature that is causing the debugger to load stale JS code.
To fix the issue click on the "Network" tab in the debugger and check the "disable cache" option. Now you should see your changes work.
For more info check this out:
https://github.com/jhen0409/react-native-debugger/issues/423
I had this problem using Expo
I managed to solve it, move the device until the settings appear, then disable the "Debug Remote JS" option.

ionic mobile app gives white screen

I have created one ionic app it runs perfectly fine in browser but when I convert it into app it gives white screen.
I have already install white list plugin and allowed all url in config and also have kept meta tag. Am not able to find any other solution.
When kept simple html file am able to view it.
Any help will be grateful.May be good way to debug will be also good.
Connect your phone to PC with USB cable and remember to keep USB Debugging On. Now, navigate to chrome://inspect. You'll find the device name and click on "inspect". On Console tab, the error list will give you a hint about what is wrong there.
In my case, a custom service was Injected in controller which had been removed at some time as It was not used anywhere.
Ok just answering this question so it will be helpful to all.
Below blog was helpful for me that how I can debug
http://gonehybrid.com/how-to-debug-the-white-screen-of-death-in-your-ionic-app/
And guess what was issue, folder name in app is case sensitive. I was just need to change a folder name as per exact case sensitive path I provide in index file.
Mostly such thing occures because of a javascript error. You say it runs in your browser. Are there some exception in the console?
Not everythings is equal between browser and device, for example plugins. You have to be sure, that all used plugins are installed properly.
If you deploy on android, you can use android monitor to get console output. On ios xcode has already an integrated debugger.
I had this horrible issue because I compiled my Android application with Cordova 6.x and the project worked with CrossWalk plugin. In my case, the solution was uninstalling Crosswalk. If your project has installed that plugin, try to uninstall it and compile your project again.

Resources