Giter Club home page Giter Club logo

react-native-debugger's Introduction

React Native Debugger

Build Status Build status Windows Dependency Status devDependency Status

React Native Debugger

This is a standalone app for debugging React Native apps, it's based on the official Remote Debugger, and includes React Inspector / Redux DevTools.

Installation

The prebuilt binaries can be found on the releases page.

For macOS, you can use Homebrew Cask to install:

$ brew update && brew cask install react-native-debugger

Usage

You must make sure all http://localhost:8081/debugger-ui pages are closed, then open the app to wait state, and reload JS with your simulator / device.

Also, you can use react-native-debugger-open, it can:

  • Replace open debugger-ui with Chrome to open React Native Debugger from react-native packager, saving you from closing the debugger-ui page everytime it automatically opens :)
  • Detect react-native packager port then send to the app, if you launch packager with custom --port, this will very useful

Platform support

Debugger

The Debugger part is referenced from react-native debugger-ui.

React Inspector

The React Inspector is used react-devtools-core/standalone, it will open a WebSocket server (port: 8097) to waiting React Native connection.

Use real device

Redux DevTools (and RemoteDev on local even MobX)

We used RemoteDev App and made the API same with Redux DevTools Extension!

If you're enabled Debug JS remotely with React Native Debugger, the following API is already included in global:

  • window.__REDUX_DEVTOOLS_EXTENSION__
  • window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__

See usage of redux-devtools-extension for more information.

Examples

Debugging tips

Get $r of React DevTools or global variables of react-native runtime in the console

You need to switch worker thread for console, open Console tab on Chrome DevTools, tap top context and change to RNDebuggerWorker.js context:

2016-11-05 6 56 45

Inpsect network requests by Network tab of Chrome DevTools (See also #15)

We can do:

// const bakXHR = global.XMLHttpRequest;
// const bakFormData = global.FormData;
global.XMLHttpRequest = global.originalXMLHttpRequest ?
  global.originalXMLHttpRequest :
  global.XMLHttpRequest;
global.FormData = global.originalFormData ?
  global.originalFormData :
  global.FormData;

WARNING It will break NSExceptionDomains for iOS, because originalXMLHttpRequest is from debugger worker (it will replace native request), so we should be clear about the difference in debug mode.

If you want to inspect deeper network requests (Like request of Image), use tool like Stetho will be better.

Troubleshooting

[Android] React Inspector get stuck at "Connecting to React…" (#45)

Maybe the problem is related to requestIdleCallback API (try to check if it not work on debug mode), make sure the device time is the same as the host (your computer), otherwise:

// Not recommended
if (__DEV__) {
  window.requestIdleCallback = null
  window.cancelIdleCallback = null
}
// Make sure it before call at `import { ... } from 'react-native'`

Or use polyfill instead. (Like: react-devtools/agent/Bridge.js#L21-L22)

Development

# Just clone it
$ git clone https://github.com/jhen0409/react-native-debugger
$ cd react-native-debugger && npm install

# Run on development
$ npm run dev:webpack  # Then open the another
$ npm run dev:electron

# Run on production
$ npm run build
$ npm start

# Run test
$ npm run lint
$ npm test

# Pack
$ npm run pack-macos
$ npm run pack-linux
$ npm run pack-windows
$ npm run pack # all

If you want to build binaries yourself, please remove electron/update.js (and electon/main.js usage), osx-sign in scripts/package-macos.sh.

Credits

LICENSE

MIT

react-native-debugger's People

Contributors

jhen0409 avatar vespakoen avatar kraffslol avatar tomauty avatar yuanchuan avatar kwv avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.