infinitered / reactotron

A desktop app for inspecting your React JS and React Native projects. macOS, Linux, and Windows.
https://docs.infinite.red/reactotron/
MIT License
14.93k stars 944 forks source link

createEnhancer() is not a function #1180

Open iutin opened 4 years ago

iutin commented 4 years ago

I have this issue... TypeError: _reactotronReactNative.default.createEnhancer is not a function. (In '_reactotronReactNative.default.createEnhancer()', '_reactotronReactNative.default.createEnhancer' is undefined)

"reactotron-react-native": "3.6.5", "reactotron-redux": "3.1.2",

My code: `

import {
  createStore,
  combineReducers
} from 'redux';
import Reactotron from 'reactotron-react-native';
import reducer from './reducers/RootReducer';

const mainReducer = combineReducers({
  root: reducer,
});

export default () => createStore(mainReducer, Reactotron.createEnhancer());

` Does someone have any suggestions? Thanks!

renato-bohler commented 4 years ago

In case anyone needs: it happened to me aswell.

In my case, I was missing these changes in my ReactotronConfig file:

+ import { reactotronRedux } from 'reactotron-redux';

 const tron = Reactotron.configure()
   .useReactNative()
+  .use(reactotronRedux())
   .setAsyncStorageHandler(AsyncStorage)
   .connect();

+ export default tron;

It seems that use(reactotronRedux()) adds a createEnhancer function on Reactotron.

Alirez14 commented 3 years ago

I have this issue... TypeError: _reactotronReactNative.default.createEnhancer is not a function. (In '_reactotronReactNative.default.createEnhancer()', '_reactotronReactNative.default.createEnhancer' is undefined)

"reactotron-react-native": "3.6.5", "reactotron-redux": "3.1.2",

My code: `

import {
  createStore,
  combineReducers
} from 'redux';
import Reactotron from 'reactotron-react-native';
import reducer from './reducers/RootReducer';

const mainReducer = combineReducers({
  root: reducer,
});

export default () => createStore(mainReducer, Reactotron.createEnhancer());

` Does someone have any suggestions? Thanks!

you must not import it from "import Reactotron from 'reactotron-react-native';" but rather " import reactotron from '../../ReactotronConfig';" --> config file which you have created

sclavijo93 commented 2 years ago

Thanks @Alirez14 you saved my day

AmitGiri2023 commented 4 months ago

I'm still facing the same issue only on on DEV environment TypeError: reactotron.createEnhancer is not a function (it is undefined), js engine: hermes

redux store:

import ReduxThunk, {withExtraArgument} from 'redux-thunk';
import {persistReducer, persistStore} from 'redux-persist';
import rootReducer from './combineReducers';
import AsyncStorage from '@react-native-async-storage/async-storage';

const rootPersistConfig = {
  key: 'root',
  storage: AsyncStorage,
  whitelist: ['persistorReducer'],
};

const persistedReducer = persistReducer(rootPersistConfig, rootReducer);
const middlewareEnhancer = applyMiddleware(withExtraArgument(ReduxThunk));
let enhancers;
if (__DEV__) {
  const reactotron = require('../../../ReactotronConfig');
  enhancers = compose(middlewareEnhancer, reactotron.createEnhancer());
} else {
  enhancers = compose(middlewareEnhancer);
}
export const store = createStore(persistedReducer, enhancers);
export const persistor = persistStore(store);

Reactotron config:

import {reactotronRedux} from 'reactotron-redux';
import AsyncStorage from '@react-native-async-storage/async-storage';
console.tron = Reactotron;
const reactotron = Reactotron.setAsyncStorageHandler(AsyncStorage)
  .configure() // controls connection & communication settings
  .use(reactotronRedux(), networking())
  .useReactNative() // add all built-in react native plugins
  .connect(); // let's connect!

export default reactotron;
AmitGiri2023 commented 4 months ago

I'm still facing the same issue only on on DEV environment TypeError: reactotron.createEnhancer is not a function (it is undefined), js engine: hermes

redux store:

import ReduxThunk, {withExtraArgument} from 'redux-thunk';
import {persistReducer, persistStore} from 'redux-persist';
import rootReducer from './combineReducers';
import AsyncStorage from '@react-native-async-storage/async-storage';

const rootPersistConfig = {
  key: 'root',
  storage: AsyncStorage,
  whitelist: ['persistorReducer'],
};

const persistedReducer = persistReducer(rootPersistConfig, rootReducer);
const middlewareEnhancer = applyMiddleware(withExtraArgument(ReduxThunk));
let enhancers;
if (__DEV__) {
  const reactotron = require('../../../ReactotronConfig');
  enhancers = compose(middlewareEnhancer, reactotron.createEnhancer());
} else {
  enhancers = compose(middlewareEnhancer);
}
export const store = createStore(persistedReducer, enhancers);
export const persistor = persistStore(store);

Reactotron config:

import {reactotronRedux} from 'reactotron-redux';
import AsyncStorage from '@react-native-async-storage/async-storage';
console.tron = Reactotron;
const reactotron = Reactotron.setAsyncStorageHandler(AsyncStorage)
  .configure() // controls connection & communication settings
  .use(reactotronRedux(), networking())
  .useReactNative() // add all built-in react native plugins
  .connect(); // let's connect!

export default reactotron;

My issue got resolved after replacing const reactotron = require('../../../ReactotronConfig') with const reactotron = require('../../../ReactotronConfig').default;