Skip to content
This repository has been archived by the owner on Jan 16, 2024. It is now read-only.

Commit

Permalink
disabled Reactotron for production builds
Browse files Browse the repository at this point in the history
  • Loading branch information
norbertschuler committed Feb 7, 2020
1 parent 3af2030 commit 928cd68
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 33 deletions.
15 changes: 5 additions & 10 deletions ReactotronConfig.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,13 @@
import Reactotron from 'reactotron-react-js';
import { reactotronRedux } from 'reactotron-redux';

const reactotron = Reactotron.configure().use(reactotronRedux());

let reactotron;
if (process.env.NODE_ENV === 'development') {
reactotron.connect(); // let's connect!
// uncomment the following lines and use the command
// adb reverse tcp:9090 tcp:9090
reactotron = Reactotron.configure()
.use(reactotronRedux())
.connect(); // let's connect!
// to make it work with an Android emulator:
// .connect({
// enabled: true,
// host: '10.1.0.22', // server ip
// port: 9090
// }); // let's connect!
// adb reverse tcp:9090 tcp:9090
}

export default reactotron;
23 changes: 10 additions & 13 deletions ReactotronConfig.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,15 @@ import AsyncStorage from '@react-native-community/async-storage';
import Reactotron from 'reactotron-react-native';
import { reactotronRedux } from 'reactotron-redux';

const reactotron = Reactotron.setAsyncStorageHandler(AsyncStorage)
.configure() // controls connection & communication settings
.use(reactotronRedux())
.useReactNative() // add all built-in react native plugins
.connect(); // let's connect!
// uncomment the following lines and use the command
// adb reverse tcp:9090 tcp:9090
// to make it work with an Android emulator:
// .connect({
// enabled: true,
// host: '10.1.0.22', // server ip
// port: 9090
// }); // let's connect!
let reactotron;
if (__DEV__) {
reactotron = Reactotron.setAsyncStorageHandler(AsyncStorage)
.configure() // controls connection & communication settings
.use(reactotronRedux())
.useReactNative() // add all built-in react native plugins
.connect(); // let's connect!
// to make it work with an Android emulator:
// adb reverse tcp:9090 tcp:9090
}

export default reactotron;
21 changes: 11 additions & 10 deletions app/stores/TreecounterStore.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { createStore, applyMiddleware, compose } from 'redux';
import Reactotron from '../../ReactotronConfig';
import reactotron from '../../ReactotronConfig';
import thunkMiddleware from 'redux-thunk';
import logger from 'redux-logger';
import middlewares from './middlewares';
Expand Down Expand Up @@ -33,17 +33,18 @@ export default function configureStore() {
(window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose);

let middleware = [...middlewares, thunkMiddleware];

if (process.env.NODE_ENV === 'development') {
middleware.push(logger);
}

return createStore(
reducers,
commonInitialState,
composeEnhancers(
let enhancers;
if (reactotron) {
enhancers = composeEnhancers(
applyMiddleware(...middleware),
Reactotron.createEnhancer()
)
);
reactotron.createEnhancer()
);
} else {
enhancers = composeEnhancers(applyMiddleware(...middleware));
}

return createStore(reducers, commonInitialState, enhancers);
}

0 comments on commit 928cd68

Please sign in to comment.