Reactotron: Not working with Expo

Created on 10 Mar 2019  路  6Comments  路  Source: infinitered/reactotron

Hi,

I'm trying to setup reactotron with expo, I had it working with a older version of react native but now I am migrating to expo lastest version and can't make it work.

This is my config.

// reactotronConfig.js

import { reactotronRedux } from "reactotron-redux";
import Reactotron from "reactotron-react-native";

export function configureReactotron() {
  return Reactotron.configure()
    .useReactNative()
    .use(reactotronRedux())
    .connect(); // let's connect!
}

and in App.js

import { configureReactotron } from "./reactotronConfig";
import Reactotron from "reactotron-react-native";
import { applyMiddleware } from "redux";
import ReduxThunk from "redux-thunk";
//...
if (__DEV__) {
  configureReactotron();
  store = Reactotron.createStore(
    (state, action) => state,
    {},
    applyMiddleware(ReduxThunk)
  );
}

and the error is

 _reactotronReactNative.default.createStore is not a function. (In '_reactotronReactNative.default.createStore(function (state, action) {
   return state;
 }, {}, (0, _redux.applyMiddleware)(_reduxThunk.default))', '_reactotronReactNative.default.createStore' is undefined)
"reactotron-react-native": "^3.2.1",
 "reactotron-redux": "^3.1.0"
"expo": "^32.0.0"

Most helpful comment

This is my working configuration, hope can help someone

"reactotron-react-native": "^3.2.1",
"reactotron-redux": "^2.1.0",

import { NativeModules } from "react-native";
import Reactotron, {
    asyncStorage,
    networking,
    trackGlobalErrors
} from "reactotron-react-native";
import * as reactotronRedux from "reactotron-redux";
import { applyMiddleware, compose, createStore, Store } from "redux";

// get the host url, needed for when running from device
const scriptURL = NativeModules.SourceCode.scriptURL;
let scriptHostname = scriptURL.split("://")[1].split(":")[0];
let reactotron = Reactotron.configure({ host: scriptHostname }) /
                .use(trackGlobalErrors({}))
                // .use(openInEditor())
                // .use(overlay())
                .use(asyncStorage({}))
                .use(networking())
                //@ts-ignore
                .useReactNative() // add all built-in react native plugins
                .use(reactotronRedux.reactotronRedux()) //  <- here i am!
                .connect(); // let's connect!

            let createStoreFunction = createStore;
            if (__DEV__) {
                createStoreFunction = reactotron.createStore;
            }
            const store = createStoreFunction<AppState>(
                combineReducers,
                {
                    my store initial data
                },
                compose(applyMiddleware(thunk))
            );

All 6 comments

Well,

After trying a few configurations this worked for me if anyone is having trouble configuring the tool with expo.

// App.js

import { Provider } from "react-redux";
import { applyMiddleware, createStore, compose } from "redux";
import ReduxThunk from "redux-thunk";
import { reactotronRedux } from "reactotron-redux";
import Reactotron from "reactotron-react-native";

let store;

if (__DEV__) {
  const reactotron = Reactotron.configure({ port: 9090 })
    .useReactNative() 
    .use(reactotronRedux())
    .connect();
  store = createStore(
    (state = {}, action) => state,
    compose(
      applyMiddleware(ReduxThunk),
      reactotron.createEnhancer()
    )
  );
} else {
  store = createStore(
    (state = {}, action) => state,
    applyMiddleware(ReduxThunk)
  );
}
....

reactotron.createEnhancer() is not a function

"reactotron-react-native": "^3.2.1",
"reactotron-redux": "^3.1.0",

Is that TypeScript telling you that it isn鈥檛 a function or at runtime? Can you show the reactotron configuration code you are using?

At runtime, I use same as you:

const reactotron = Reactotron.configure({ port: 9090 })
            .useReactNative() 
            .use(reactotronRedux())
            .connect();
        store = createStore(
            (state = {}, action) => state,
            compose(
            applyMiddleware(...middleware),
            reactotron.createEnhancer()
            )
        );

I will see about recreating this issue this weekend

This is my working configuration, hope can help someone

"reactotron-react-native": "^3.2.1",
"reactotron-redux": "^2.1.0",

import { NativeModules } from "react-native";
import Reactotron, {
    asyncStorage,
    networking,
    trackGlobalErrors
} from "reactotron-react-native";
import * as reactotronRedux from "reactotron-redux";
import { applyMiddleware, compose, createStore, Store } from "redux";

// get the host url, needed for when running from device
const scriptURL = NativeModules.SourceCode.scriptURL;
let scriptHostname = scriptURL.split("://")[1].split(":")[0];
let reactotron = Reactotron.configure({ host: scriptHostname }) /
                .use(trackGlobalErrors({}))
                // .use(openInEditor())
                // .use(overlay())
                .use(asyncStorage({}))
                .use(networking())
                //@ts-ignore
                .useReactNative() // add all built-in react native plugins
                .use(reactotronRedux.reactotronRedux()) //  <- here i am!
                .connect(); // let's connect!

            let createStoreFunction = createStore;
            if (__DEV__) {
                createStoreFunction = reactotron.createStore;
            }
            const store = createStoreFunction<AppState>(
                combineReducers,
                {
                    my store initial data
                },
                compose(applyMiddleware(thunk))
            );
Was this page helpful?
0 / 5 - 0 ratings

Related issues

dhruwal picture dhruwal  路  3Comments

Ashoat picture Ashoat  路  4Comments

Anahkiasen picture Anahkiasen  路  5Comments

lndgalante picture lndgalante  路  4Comments

VansonLeung picture VansonLeung  路  4Comments