调试 React Native 涉及用于诊断问题的工具和技术 — React Native debugger/DevTools、console logging、Flipper、error messages 和特定于平台的调试。有效的调试是一项必要的实用技能。
核心调试工具
✓ CONSOLE.LOG → log values/flow (basic but effective; shows in the Metro terminal/debugger)
✓ DEV MENU (shake device / Cmd+D / Cmd+M) → reload, debug, performance monitor, inspector
✓ REACT DEVTOOLS → inspect the component tree, props, state, hooks
✓ DEBUGGER → set breakpoints, step through JS (Chrome DevTools / Hermes debugger / IDE)
✓ ELEMENT INSPECTOR → inspect/tap UI elements to see their styles/hierarchy
