Reactotron: 'f is not a function' when using Reactotron.createStore

Created on 21 Dec 2016  路  10Comments  路  Source: infinitered/reactotron

I am trying to use Reactotron with react-native, and it worked flawlessly before trying it with Redux. Now it gives me an error as in the image:

screen shot 2016-12-22 at 0 16 22

This only happens when I use Reactotron.createStore, and it works as expected with the Redux createStore. I looked around the source code but couldn't figure out what is happening.. any idea? As you can see from the call stack, this is at initialization of the app.

Here is the source code:

const configureDevelopmentEnvironment = () => {
    configureReactotron();
    return configureDevStore();
}
const configureReactotron = () => {
    const ReactotronSet = require('reactotron-react-native');
    const reactotronRedux = require('reactotron-redux').reactotronRedux;

    const Reactotron = ReactotronSet.default;

    Reactotron
        .configure()
        .use(reactotronRedux())
        .use(ReactotronSet.openInEditor())
        .use(ReactotronSet.trackGlobalErrors())
        .connect();

    console.tron = Reactotron;
    Reactotron.clear();
}
const configureDevStore = () => {
    const dummyInitialState = require('./dummyInitialState').default;
    const Reactotron = require('reactotron-react-native').default;

    const store = Reactotron.createStore(reducersSet, dummyInitialState)
    return store;
}

Library Versions:

  • react-native : 0.39.0
  • redux: 3.6.0
  • reactotron: 1.6.0
  • reactotron-redux: 1.6.1

Any help would be appreciated. Cheers!

P.S. Great tool, love it! :)

bug

Most helpful comment

Thanks for the prompt response. I think you are right, the bug is probably in the assignment of the initialState and enhancer.

I just did this:

const store = Reactotron.createStore(reducersSet, dummyInitialState, applyMiddleware())

and it is working as expected. Cheers!

All 10 comments

Looks like I have a bug in there. Can you try adding a 3rd parameter to the Reactotron.createStore() call?

Maybe just try something silly like:

import { compose } from 'redux'
Reactotron.createStore(reducersSet, dummyInitialState, compose([]))

I know it doesn't do anything, but it should fulfill the contract of what Reactotron.createStore is expecting. With 2 parameters, I think I'm incorrectly assigning position 2 to the middleware and not the initial state as you're expecting.

Thanks for a fantastic bug report!

Thanks for the prompt response. I think you are right, the bug is probably in the assignment of the initialState and enhancer.

I just did this:

const store = Reactotron.createStore(reducersSet, dummyInitialState, applyMiddleware())

and it is working as expected. Cheers!

Hello and thanks for Reactotron!

I'm seeing the same problem but I'm using a non-empty compose message and am not using any 'dummyInitialState'.

What parameters should I send to Reactotron.createStore? Below results in the f(composed) "Array is not a function" error.

    return Reactotron.createStore(reducer, compose(
      middleware,
      createReactotronTrackingEnhancer(Reactotron, {})
    ));

What is middleware is your setup? Is it an array or a function that has run through applyMiddleware()?

Feel free to re-open if you're still stuck.

This works:

const store: Store = Reactotron.createStore(reducers,applyMiddleware());

But, this does not:

const store: Store = Reactotron.createStore(reducers);

It says that

a is not a function

Since the 'original' createStore accepts being called with one single parameter, I think Reactotron should have the same 'signature', 'interface' or behaviour.

  • BTW: I'm talking about reactotron-react-native. Installed today with npm.

I agree 100%. #468

Suggestion: Could add the applyMiddleware() part in the get started guide, I hit the "a is not a function" error too and was puzzled.

Unfortunately this is still a thing...

It still happened to me, 2018

store = reactotron.createStore(reducer); gives me a is not a function

store = reactotron.createStore(reducer, {}, applyMiddleware()); fixed the problem

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Eyesonly88 picture Eyesonly88  路  4Comments

nonameolsson picture nonameolsson  路  5Comments

andrewvy picture andrewvy  路  4Comments

sylar picture sylar  路  4Comments

dhruwal picture dhruwal  路  3Comments