reactotron: null is not an object (evaluating 'reduxStore.getState')

2017-01-04 2 17 47

I met this error. When I refresh several times, sometimes it runs.

This is my files

// reactoron-config.js
import Reactotron, { trackGlobalErrors } from 'reactotron-react-native';
import apisaucePlugin from 'reactotron-apisauce';  // <--- import
import { reactotronRedux } from 'reactotron-redux';
import sagaPlugin from 'reactotron-redux-saga';

console.tron = Reactotron;

Reactotron
  .configure() // we can use plugins here -- more on this later
  .use(trackGlobalErrors()) // <--- here we go!
  .use(apisaucePlugin())
  .use(reactotronRedux())
  .use(sagaPlugin())
  .connect(); // let's connect!

export default Reactotron;
// configureStore.js
import { applyMiddleware, compose } from 'redux';
import createSagaMiddleware from 'redux-saga';
import thunk from 'redux-thunk';

import Reactotron from '../../env/reactotron-config';

import reducers from '../ducks';
import rootSaga from '../saga';

import googleAnalytics from './middleware/googleAnalytics';

const isDebuggingInChrome = __DEV__ && !!window.navigator.userAgent;
const sagaMonitor = Reactotron.createSagaMonitor();

function configureStore(onComplete) {
  const sagaMiddleware = createSagaMiddleware({ sagaMonitor });

  const store = Reactotron.createStore(reducers, {}, compose(
    applyMiddleware(sagaMiddleware, thunk, googleAnalytics),
  ));
  sagaMiddleware.run(rootSaga);

  if (isDebuggingInChrome) {
    window.store = store;
  }
  setTimeout(() => {
    onComplete(store.getState());
  });

  return store;
}

// Setup.js
class Setup extends Component {
  constructor() {
    super();
    GoogleAnalytics.setTrackerId('UA-86299762-1');
    this.state = {
      isLoading: true,
      store: configureStore((state) => {
        this.setState({ isLoading: false });
        if (state.user.nickname) {
          const { nickname, school } = state.user;
          GoogleAnalytics.setUser(nickname);
          setCrashlytics(nickname, school);
        }
      }),
    };
    // console.disableYellowBox = true;
  }

  render() {
    if (this.state.isLoading) {
      return <LoadingScreen />;
    }
    return (
      <Provider store={this.state.store}>
        <App />
      </Provider>
    );
  }
}

RN version: 0.38 reactotron-react-native: 1.6.0 reactotron-redux: 1.6.1

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 5
  • Comments: 23 (7 by maintainers)

Commits related to this issue

Most upvoted comments

I fixed this flow the document https://github.com/infinitered/reactotron/blob/master/docs/plugin-redux.md

Then, where you create your Redux store, instead of using Redux’s createStore, you can use Reactotron’s createStore which has the same interface.

const store = Reactotron.createStore(rootReducer, compose(middleware))

is there any update for this open item? Already try to move it to componentWillMount but still throwing that error only when Reactotron open. Very weird

Calling .connect() after .createStore() fixed the error for me. I’m not sure if it’s that call order or simply delay calling .connect() solved the problem, but definitely there was a weird race condition in the background.

This should be clearly documented.

@skellock That solved it for me. Thanks.

Reactotron setup still happens in my config file, only the connect() moves to cwm: if (__DEV__) Reactotron.connect();

Try moving the Reactotron.connect() into the componentWillMount() of your first component. Same thing?

I only changed my code like this.

const store = configureStore();

class Setup extends Component {
  render() {
    return (
      <Provider store={store}>
        <App />
      </Provider>
    );
  }
}