|
| 1 | +# Learn: React Native API Debugger |
| 2 | + |
| 3 | +Welcome to the **React Native API Debugger** learning guide! |
| 4 | +This resource is built for students, educators, and anyone eager to learn about debugging, inspecting, and analyzing network requests in React Native applications. |
| 5 | + |
| 6 | +--- |
| 7 | + |
| 8 | +## 🚀 What Will You Learn? |
| 9 | + |
| 10 | +- **How to intercept and inspect network requests** in a React Native app. |
| 11 | +- **How to debug APIs visually** using a draggable overlay. |
| 12 | +- **How to use advanced features** like copying cURL, device shake, and filtering. |
| 13 | +- **How to integrate optional native modules** in a cross-platform project. |
| 14 | +- **Best practices for debugging and securing mobile apps.** |
| 15 | + |
| 16 | +--- |
| 17 | + |
| 18 | +## 🛠️ Prerequisites |
| 19 | + |
| 20 | +- Basic knowledge of [React Native](https://reactnative.dev/docs/getting-started). |
| 21 | +- Node.js and npm installed on your machine. |
| 22 | +- A working React Native project (Expo or CLI). |
| 23 | + |
| 24 | +--- |
| 25 | + |
| 26 | +## 📦 Getting Started |
| 27 | + |
| 28 | +### 1. Install the Package |
| 29 | + |
| 30 | +```bash |
| 31 | +npm install react-native-api-debugger |
| 32 | +``` |
| 33 | + |
| 34 | +### 2. (Optional) Install Peer Dependencies |
| 35 | + |
| 36 | +To unlock advanced features, install these as needed: |
| 37 | + |
| 38 | +```bash |
| 39 | +npm install @react-native-clipboard/clipboard react-native-shake react-native-gesture-handler react-native-reanimated |
| 40 | +``` |
| 41 | + |
| 42 | +> The debugger will throw clear errors if you enable an advanced feature but haven't installed its dependency. |
| 43 | +
|
| 44 | +--- |
| 45 | + |
| 46 | +## 🧑💻 Hands-On Exercise |
| 47 | + |
| 48 | +### Step 1: Basic Setup |
| 49 | + |
| 50 | +Add the overlay to your app: |
| 51 | + |
| 52 | +```typescript |
| 53 | +import React, { useEffect } from 'react'; |
| 54 | +import { View } from 'react-native'; |
| 55 | +import { networkLogger, NetworkLoggerOverlay } from 'react-native-api-debugger'; |
| 56 | + |
| 57 | +export default function App() { |
| 58 | + useEffect(() => { |
| 59 | + networkLogger.setupInterceptor(); |
| 60 | + }, []); |
| 61 | + |
| 62 | + return ( |
| 63 | + <View style={{ flex: 1 }}> |
| 64 | + {/* Your app content */} |
| 65 | + <NetworkLoggerOverlay |
| 66 | + draggable={false} |
| 67 | + enableDeviceShake={false} |
| 68 | + useCopyToClipboard={false} |
| 69 | + showRequestHeader={false} |
| 70 | + showResponseHeader={false} |
| 71 | + networkLogger={networkLogger} |
| 72 | + /> |
| 73 | + </View> |
| 74 | + ); |
| 75 | +} |
| 76 | +``` |
| 77 | + |
| 78 | +### Step 2: Enable Features |
| 79 | + |
| 80 | +Try enabling features one by one. For example, after installing `@react-native-clipboard/clipboard`, set `useCopyToClipboard={true}` in the overlay props and see how copy-to-clipboard works. |
| 81 | + |
| 82 | +### Step 3: Experiment |
| 83 | + |
| 84 | +- Make network requests in your app (e.g., with `fetch`). |
| 85 | +- Observe them appearing in the overlay. |
| 86 | +- Try filtering requests, copying cURL commands, and inspecting headers. |
| 87 | + |
| 88 | +--- |
| 89 | + |
| 90 | +## 🎓 Learning Activities |
| 91 | + |
| 92 | +### Activity 1: Debug a Real API |
| 93 | + |
| 94 | +- Integrate the debugger into a simple app. |
| 95 | +- Make requests to a public API (like [JSONPlaceholder](https://jsonplaceholder.typicode.com/)). |
| 96 | +- Use the overlay to inspect request/response data. |
| 97 | + |
| 98 | +### Activity 2: Secure Your App |
| 99 | + |
| 100 | +- Discuss why you should only use network debugging tools in development. |
| 101 | +- Explore how to exclude sensitive endpoints (see `excludeUrls` in the docs). |
| 102 | + |
| 103 | +### Activity 3: Extend the Debugger |
| 104 | + |
| 105 | +- Propose a new feature (e.g., dark mode or exporting logs). |
| 106 | +- Fork the repo, add your feature, and open a pull request! |
| 107 | + |
| 108 | +--- |
| 109 | + |
| 110 | +## 💡 Discussion Questions |
| 111 | + |
| 112 | +- Why is it important to inspect network requests during development? |
| 113 | +- What risks are associated with logging network data in production? |
| 114 | +- How can modular, optional dependencies improve the developer experience in React Native? |
| 115 | + |
| 116 | +--- |
| 117 | + |
| 118 | +## 🏆 Share Your Learning |
| 119 | + |
| 120 | +- Post your project or screenshots using `react-native-api-debugger` on social media. |
| 121 | +- Tag [@cmcWebCode](https://x.com/cmcWebCode) or open a discussion in [GitHub Discussions](https://github.com/cmcWebCode40/react-native-api-debugger/discussions). |
| 122 | + |
| 123 | +--- |
| 124 | + |
| 125 | +## 📚 More Resources |
| 126 | + |
| 127 | +- [React Native Docs](https://reactnative.dev/docs/getting-started) |
| 128 | +- [API Debugging Basics](https://developer.mozilla.org/en-US/docs/Web/HTTP/Overview) |
| 129 | +- [GitHub Education](https://education.github.com/) |
| 130 | + |
| 131 | +--- |
| 132 | + |
| 133 | +**Happy Debugging! 🚦** |
0 commit comments