diff --git a/learn/react-native/debugging-in-react-native.md b/learn/react-native/debugging-in-react-native.md new file mode 100644 index 000000000..5d3ba2c6f --- /dev/null +++ b/learn/react-native/debugging-in-react-native.md @@ -0,0 +1,424 @@ +--- +title: "Debugging - React Native Application" +id: "debugging-in-react-native" +sidebar_label: "Debugging - React Native Application" +--- +--- + +WaveMaker Mobile Applications are built using Expo & React Native, so you can debug them like any other Expo React Native application. Along with the already exiting tools and methods to debug Expo React Native Apps, WaveMaker also provides specialized tool like **[WavePulse](#wavepulse)** to debug WaveMaker Mobile Applications. + +For debugging we can run application in following ways. + +- **[Web Preview](test-run)**: In studio, the application can be previewed on web browser at any point of development. It gives us very quick and easy way to preview our appliction. +- **[Expo Go / Development Build](expo-debug)**: We can run our Expo project locally using Expo CLI, there are two ways to run it. + - **Expo Go** - It is a mobile application to preview and test React Native projects on your device in real time without needing a separate build process. + - **Expo Development build** - It is a build of your React Native app that includes native code, enabling you to test features not supported by Expo Go. +- **[App Installers (APK/IPA)](build-installers)**: Mobile apps are packaged into installers—APK for Android and IPA for iOS. These files allow apps to be installed on devices. There are two types of builds: + - **Debug Build:** Used for development and testing. It includes extra tools for debugging and is not optimized for performance. + - **Release Build:** A final, optimized version for users. It runs faster, has no debug tools, and is required for app stores. + +Below table gives few debugging tools along with where they are supported. + +| Platforms →
Tools ↓ | Web Preview | Expo (Go / Dev Build) | Release Build (APK/IPA) | +| ------ | :-----: | :-----: | :-----: | +| **Chrome DevTools** | ✅ | - | - | +| **React DevTools** | ✅ | ✅ | - | +| **React Native DevTools** | - | ✅ | - | +| **WavePulse** | ✅ | ✅ | ✅ | + +## Common Panels in Debugging Tools + +Different debugging tools offer various features, often grouped into panels. These panels help inspect and experiment with different aspects of an app. Here are some commonly used ones: + +- **Console**: View log messages, errors, or debugging information from JavaScript. Execute JavaScript commands directly. View stack traces for errors and warnings. +- **Elements/Components**: Inspect and analyse elements making up the page, usually displayed in hierarchical manner. It can also show details related to those elements like styles, state etc. We can also hover/select over elements to highlight it on the application we are debugging. +- **Sources**: View and debug JavaScript code by setting breakpoints. View and step through code execution line by line. Use Watch expressions and Call Stack to trace program flow. +- **Network**: Monitor and analyze API calls, HTTP requests, responses, and timing. View resource load order and performance metrics. Inspect request headers, response data, and cookies. +- **Performance/Timeline/Profiler**: Record and analyze page performance. View timelines for CPU usage, scripting, rendering, and layout tasks. Identify bottlenecks that slow down the application. +- **Memory/Storage**: View storage usage by application. Detect memory leaks and optimize memory usage. + +:::note +Panels, its UI and features present, will depend on the tool and its version being used. +::: + +## Enabling Logs in WaveMaker Mobile App + +- You must enable logs to see logs in console when running app, it can be enabled in `wm_rn_config.json`. +- If running app on expo server, you need restart expo server whenever you make changes to config files like `wm_rn_config.json`. +- If WavePulse is enable, source for every log will be shown as wavepulse.agent.js as it intercepts the logs. +- WavePulse is always enabled in web preview. +- Steps to enable logs in WaveMaker + - Go to 'File Explorer' in Studio. + - Open src > main > webapp > wm_rn_config.json + - Add `"enableLogs" : true` in `preferences` object. + +
+