Skip to content
This repository has been archived by the owner on Mar 9, 2021. It is now read-only.

Updates Reactotron to the latest version & techniques. #59

Merged
merged 3 commits into from
May 25, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 6 additions & 47 deletions boilerplate/App/Config/ReactotronConfig.js
Original file line number Diff line number Diff line change
@@ -1,48 +1,16 @@
import { StartupTypes } from '../Redux/StartupRedux'
import Config from '../Config/DebugConfig'
import Immutable from 'seamless-immutable'
import Reactotron, { overlay, trackGlobalErrors } from 'reactotron-react-native'
import apisaucePlugin from 'reactotron-apisauce'
import { reactotronRedux } from 'reactotron-redux'
import Reactotron from 'reactotron-react-native'
import { reactotronRedux as reduxPlugin } from 'reactotron-redux'
import sagaPlugin from 'reactotron-redux-saga'

if (Config.useReactotron) {
// https://github.com/infinitered/reactotron for more options!
Reactotron
.configure({
// host: '10.0.3.2' // default is localhost (on android don't forget to `adb reverse tcp:9090 tcp:9090`)
name: 'Ignite App' // would you like to see your app's name?
})

// forward all errors to Reactotron
.use(trackGlobalErrors({
// ignore all error frames from react-native (for example)
veto: (frame) =>
frame.fileName.indexOf('/node_modules/react-native/') >= 0
}))

// register apisauce so we can install a monitor later
.use(apisaucePlugin())

// add overlay ability for graphics
.use(overlay())

// setup the redux integration with Reactotron
.use(reactotronRedux({
// you can flag some of your actions as important by returning true here
isActionImportant: action => action.type === StartupTypes.STARTUP,

// you can flag to exclude certain types too... especially the chatty ones
// except: ['EFFECT_TRIGGERED', 'EFFECT_RESOLVED', 'EFFECT_REJECTED', 'persist/REHYDRATE'],

// Fires when Reactotron uploads a new copy of the state tree. Since our reducers are
// immutable with `seamless-immutable`, we ensure we convert to that format.
onRestore: state => Immutable(state)
}))

// register the redux-saga plugin so we can use the monitor in CreateStore.js
.configure({ name: 'Ignite App' })
.useReactNative()
.use(reduxPlugin({ onRestore: Immutable }))
.use(sagaPlugin())

// let's connect!
.connect()

// Let's clear Reactotron on every time we load the app
Expand All @@ -51,13 +19,4 @@ if (Config.useReactotron) {
// Totally hacky, but this allows you to not both importing reactotron-react-native
// on every file. This is just DEV mode, so no big deal.
console.tron = Reactotron
} else {
// a mock version should you decide to leave console.tron in your codebase
console.tron = {
log: () => false,
warn: () => false,
error: () => false,
display: () => false,
image: () => false
}
}
9 changes: 5 additions & 4 deletions boilerplate/App/Containers/App.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import '../Config'
import DebugConfig from '../Config/DebugConfig'
import React, { Component } from 'react'
import { Provider } from 'react-redux'
import RootContainer from './RootContainer'
Expand Down Expand Up @@ -26,7 +27,7 @@ class App extends Component {
}
}

// allow reactotron overlay for fast design
const AppWithBenefits = console.tron.overlay(App)

export default AppWithBenefits
// allow reactotron overlay for fast design in dev mode
export default DebugConfig.useReactotron
? console.tron.overlay(App)
: App
2 changes: 1 addition & 1 deletion boilerplate/App/Redux/CreateStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export default (rootReducer, rootSaga) => {

/* ------------- Saga Middleware ------------- */

const sagaMonitor = __DEV__ ? console.tron.createSagaMonitor() : null
const sagaMonitor = Config.useReactotron ? console.tron.createSagaMonitor() : null
const sagaMiddleware = createSagaMiddleware({ sagaMonitor })
middleware.push(sagaMiddleware)

Expand Down
7 changes: 0 additions & 7 deletions boilerplate/App/Services/Api.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,6 @@ const create = (baseURL = 'https://api.github.com/') => {
timeout: 10000
})

// Wrap api's addMonitor to allow the calling code to attach
// additional monitors in the future. But only in __DEV__ and only
// if we've attached Reactotron to console (it isn't during unit tests).
if (__DEV__ && console.tron) {
api.addMonitor(console.tron.apisauce)
}

// ------
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

woah, awesome!

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So we have no headers now?

facebook/react-native#934 (comment)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you open an issue if you’re having a problem? Headers are coming through fine. I haven’t tried on 0.54 though. I hear there are changes.

Copy link

@artem-russkikh artem-russkikh Mar 26, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@skellock tried on a new ignite app (RN 0.50.4), everything is ok

// STEP 2
// ------
Expand Down
21 changes: 12 additions & 9 deletions boilerplate/App/Services/RehydrationServices.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import ReduxPersist from '../Config/ReduxPersist'
import { AsyncStorage } from 'react-native'
import { persistStore } from 'redux-persist'
import StartupActions from '../Redux/StartupRedux'
import DebugConfig from '../Config/DebugConfig'

const updateReducers = (store: Object) => {
const reducerVersion = ReduxPersist.reducerVersion
Expand All @@ -11,15 +12,17 @@ const updateReducers = (store: Object) => {
// Check to ensure latest reducer version
AsyncStorage.getItem('reducerVersion').then((localVersion) => {
if (localVersion !== reducerVersion) {
console.tron.display({
name: 'PURGE',
value: {
'Old Version:': localVersion,
'New Version:': reducerVersion
},
preview: 'Reducer Version Change Detected',
important: true
})
if (DebugConfig.useReactotron) {
console.tron.display({
name: 'PURGE',
value: {
'Old Version:': localVersion,
'New Version:': reducerVersion
},
preview: 'Reducer Version Change Detected',
important: true
})
}
// Purge store
persistStore(store, config, startup).purge()
AsyncStorage.setItem('reducerVersion', reducerVersion)
Expand Down
7 changes: 3 additions & 4 deletions boilerplate/package.json.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,9 @@
"husky": "^0.13.1",
"react-addons-test-utils": "^15.3.1",
"react-dom": "^15.4.0",
"reactotron-apisauce": "^1.7.0",
"reactotron-react-native": "^1.7.0",
"reactotron-redux": "^1.7.0",
"reactotron-redux-saga": "^1.7.0"
"reactotron-react-native": "^1.11.1",
"reactotron-redux": "^1.11.1",
"reactotron-redux-saga": "^1.11.1"
},
"jest": {
"testMatch": [
Expand Down