Created
July 20, 2021 14:38
-
-
Save muneneevans/150e76ac65a6f8ad368d6abb5cf11a15 to your computer and use it in GitHub Desktop.
Reactotron
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import {createStore, applyMiddleware, compose} from 'redux'; | |
import thunk from 'redux-thunk'; | |
import {persistStore} from 'redux-persist'; | |
import reducer from './rootReducer'; | |
// ALERT disable in release build | |
const middlewares = [thunk]; | |
let store = {}; | |
if (__DEV__) { | |
const Reactotron = require('src/../ReactotronConfig').default; | |
store = createStore( | |
reducer, | |
compose(applyMiddleware(...middlewares), Reactotron.createEnhancer()), | |
); | |
} else { | |
store = createStore(reducer, compose(applyMiddleware(...middlewares))); | |
} | |
export const persistor = persistStore(store); | |
export default store; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @format | |
*/ | |
import 'react-native-gesture-handler'; | |
import {AppRegistry} from 'react-native'; | |
import App from './src'; | |
import {name as appName} from './app.json'; | |
if (__DEV__) { | |
import('./ReactotronConfig').then(() => console.log('Reactotron Configured')) | |
} | |
AppRegistry.registerComponent(appName, () => App); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import AsyncStorage from '@react-native-async-storage/async-storage'; | |
import {reactotronRedux} from 'reactotron-redux'; | |
import {NativeModules} from 'react-native'; | |
let scriptHostname; | |
let reactotron = {}; | |
if (__DEV__) { | |
const Reactotron = require('reactotron-react-native').default; // eslint-disable-line global-require | |
const scriptURL = NativeModules.SourceCode.scriptURL; | |
scriptHostname = scriptURL.split('://')[1].split(':')[0]; | |
reactotron = Reactotron.setAsyncStorageHandler(AsyncStorage) // AsyncStorage would either come from `react-native` or `@react-native-community/async-storage` depending on where you get it from | |
.configure({ | |
name: 'Pioneer Eshop', | |
host: scriptHostname, | |
}) | |
.useReactNative({ | |
asyncStorage: true, // there are more options to the async storage. | |
networking: { | |
// optionally, you can turn it off with false. | |
host: 'localhost', | |
ignoreUrls: /symbolicate/, | |
}, | |
editor: true, // there are more options to editor | |
errors: {veto: (stackFrame) => false}, // or turn it off with false | |
overlay: false, // just turning off overlay | |
}) | |
.use(reactotronRedux()); | |
reactotron.connect(); | |
} | |
export default reactotron; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment