skellock / reactotron
- четверг, 21 апреля 2016 г. в 03:13:33
JavaScript
Control, monitor, and instrument your React Native apps from the comfort of your TTY.
Control, monitor, and instrument your React Native apps. From the comfort of your TTY.
npm install reactotron --save-dev
node_modules/bin/reactotron
Might be worth creating an alias or adding it to your script section of your package.json
.
Remember, this is a development tool. It'll help you build your app. But you don't want to ship your product with this left on. :)
To use this, you need to add a few lines of code to your app.
Depending on how much support you'd like, there's a few different places you'll want to hook in.
If you have index.ios.js
or index.android.js
, you can place this code somewhere near the top:
import Reactotron from 'reactotron'
if (__DEV__) {
Reactotron.connect()
}
// wherever you create your Redux store, add the Reactotron middleware:
const store = createStore(
rootReducer,
applyMiddleware(
logger,
Reactotron.reduxMiddleware // <--- here i am!
)
)
// wherever you create your Redux store
import Reactotron from 'reactotron'
const store = createStore(...) // however you create your store
Reactotron.addReduxStore(store) // <--- here i am!
// wherever you create your API
import Reactotron from 'reactotron'
// with your existing api object, add a monitor
api.addMonitor(Reactotron.apiLog)
If you're using an Android sim and it's running 5.x or higher, you can use adb
to port forward
the right TCP port to the reactotron
server.
$ANDROID_HOME/platform-tools/adb reverse tcp:3334 tcp:3334
When you initialize the reactotron
you can tell it the server location when you connect:
Reactotron.connect('10.0.1.109')
A couple things are highest priority on my plate:
.reactotron
project-specific directory for plugins and stuffThis project is a week old, so there's some rough edges. I'm already using this on my project and hopefully you can too!
PRs and bug reports are welcome!
You want to start extending this?
npm install
npm start
cd client && npm install && react-native ios
npm link
doesn't work well because symlinks and React Native don't play well. watchman
doesn't like them.